mirror of
https://github.com/python/cpython
synced 2024-09-16 01:45:23 +00:00
Some cosmetic changes
This commit is contained in:
parent
5b8a3242c4
commit
236870439c
|
@ -1,18 +1,9 @@
|
||||||
# xml.etree test. This file contains enough tests to make sure that
|
|
||||||
# all included components work as they should.
|
|
||||||
# Large parts are extracted from the upstream test suite.
|
|
||||||
#
|
|
||||||
# PLEASE write all new tests using the standard unittest infrastructure and
|
|
||||||
# not doctest.
|
|
||||||
#
|
|
||||||
# IMPORTANT: the same tests are run from "test_xml_etree_c" in order
|
# IMPORTANT: the same tests are run from "test_xml_etree_c" in order
|
||||||
# to ensure consistency between the C implementation and the Python
|
# to ensure consistency between the C implementation and the Python
|
||||||
# implementation.
|
# implementation.
|
||||||
#
|
#
|
||||||
# For this purpose, the module-level "ET" symbol is temporarily
|
# For this purpose, the module-level "ET" symbol is temporarily
|
||||||
# monkey-patched when running the "test_xml_etree_c" test suite.
|
# monkey-patched when running the "test_xml_etree_c" test suite.
|
||||||
# Don't re-import "xml.etree.ElementTree" module in the docstring,
|
|
||||||
# except if the test is specific to the Python implementation.
|
|
||||||
|
|
||||||
import html
|
import html
|
||||||
import io
|
import io
|
||||||
|
@ -24,7 +15,7 @@
|
||||||
|
|
||||||
from itertools import product
|
from itertools import product
|
||||||
from test import support
|
from test import support
|
||||||
from test.support import TESTFN, findfile, unlink, import_fresh_module, gc_collect
|
from test.support import TESTFN, findfile, import_fresh_module, gc_collect
|
||||||
|
|
||||||
# pyET is the pure-Python implementation.
|
# pyET is the pure-Python implementation.
|
||||||
#
|
#
|
||||||
|
@ -97,6 +88,7 @@
|
||||||
|
|
||||||
|
|
||||||
class ModuleTest(unittest.TestCase):
|
class ModuleTest(unittest.TestCase):
|
||||||
|
# TODO: this should be removed once we get rid of the global module vars
|
||||||
|
|
||||||
def test_sanity(self):
|
def test_sanity(self):
|
||||||
# Import sanity.
|
# Import sanity.
|
||||||
|
@ -528,7 +520,8 @@ def test_iterparse(self):
|
||||||
|
|
||||||
events = ("start", "end", "start-ns", "end-ns")
|
events = ("start", "end", "start-ns", "end-ns")
|
||||||
context = iterparse(SIMPLE_NS_XMLFILE, events)
|
context = iterparse(SIMPLE_NS_XMLFILE, events)
|
||||||
self.assertEqual([(action, elem.tag) if action in ("start", "end") else (action, elem)
|
self.assertEqual([(action, elem.tag) if action in ("start", "end")
|
||||||
|
else (action, elem)
|
||||||
for action, elem in context], [
|
for action, elem in context], [
|
||||||
('start-ns', ('', 'namespace')),
|
('start-ns', ('', 'namespace')),
|
||||||
('start', '{namespace}root'),
|
('start', '{namespace}root'),
|
||||||
|
@ -1493,6 +1486,7 @@ def test_pickle(self):
|
||||||
self.assertEqual(len(e2), 2)
|
self.assertEqual(len(e2), 2)
|
||||||
self.assertEqualElements(e, e2)
|
self.assertEqualElements(e, e2)
|
||||||
|
|
||||||
|
|
||||||
class ElementTreeTypeTest(unittest.TestCase):
|
class ElementTreeTypeTest(unittest.TestCase):
|
||||||
def test_istype(self):
|
def test_istype(self):
|
||||||
self.assertIsInstance(ET.ParseError, type)
|
self.assertIsInstance(ET.ParseError, type)
|
||||||
|
@ -1861,7 +1855,9 @@ def test_constructor_args(self):
|
||||||
self._check_sample_element(parser.close())
|
self._check_sample_element(parser.close())
|
||||||
|
|
||||||
# Now as keyword args.
|
# Now as keyword args.
|
||||||
parser2 = ET.XMLParser(encoding='utf-8', html=[{}], target=ET.TreeBuilder())
|
parser2 = ET.XMLParser(encoding='utf-8',
|
||||||
|
html=[{}],
|
||||||
|
target=ET.TreeBuilder())
|
||||||
parser2.feed(self.sample1)
|
parser2.feed(self.sample1)
|
||||||
self._check_sample_element(parser2.close())
|
self._check_sample_element(parser2.close())
|
||||||
|
|
||||||
|
@ -1974,7 +1970,7 @@ def test_delslice(self):
|
||||||
|
|
||||||
class IOTest(unittest.TestCase):
|
class IOTest(unittest.TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
unlink(TESTFN)
|
support.unlink(TESTFN)
|
||||||
|
|
||||||
def test_encoding(self):
|
def test_encoding(self):
|
||||||
# Test encoding issues.
|
# Test encoding issues.
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
from test.support import import_fresh_module
|
from test.support import import_fresh_module
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
cET = import_fresh_module('xml.etree.ElementTree', fresh=['_elementtree'])
|
cET = import_fresh_module('xml.etree.ElementTree',
|
||||||
cET_alias = import_fresh_module('xml.etree.cElementTree', fresh=['_elementtree', 'xml.etree'])
|
fresh=['_elementtree'])
|
||||||
|
cET_alias = import_fresh_module('xml.etree.cElementTree',
|
||||||
|
fresh=['_elementtree', 'xml.etree'])
|
||||||
|
|
||||||
|
|
||||||
class MiscTests(unittest.TestCase):
|
class MiscTests(unittest.TestCase):
|
||||||
|
|
Loading…
Reference in a new issue