summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_xml_etree.py
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2012-03-23 12:24:20 (GMT)
committerEli Bendersky <eliben@gmail.com>2012-03-23 12:24:20 (GMT)
commit396e8fcf36480dacaeeeb785a3912a565294d3b7 (patch)
tree173647551cef119cdf7644b8eb009b4a48314995 /Lib/test/test_xml_etree.py
parent42243c4dcaee5fe6e680d1ea4b1b615dd0d18b10 (diff)
downloadcpython-396e8fcf36480dacaeeeb785a3912a565294d3b7.zip
cpython-396e8fcf36480dacaeeeb785a3912a565294d3b7.tar.gz
cpython-396e8fcf36480dacaeeeb785a3912a565294d3b7.tar.bz2
Issue #13782: streamline argument type-checking in ET.Element
append, extend and insert now consistently type-check their argument in both the C and Python implementations, and raise TypeError for non-Element argument. Added tests
Diffstat (limited to 'Lib/test/test_xml_etree.py')
-rw-r--r--Lib/test/test_xml_etree.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 50e5196..8a1ea0f 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1839,8 +1839,15 @@ def check_issue10777():
# --------------------------------------------------------------------
-class ElementTreeTest(unittest.TestCase):
+class BasicElementTest(unittest.TestCase):
+ def test_augmentation_type_errors(self):
+ e = ET.Element('joe')
+ self.assertRaises(TypeError, e.append, 'b')
+ self.assertRaises(TypeError, e.extend, [ET.Element('bar'), 'foo'])
+ self.assertRaises(TypeError, e.insert, 0, 'foo')
+
+class ElementTreeTest(unittest.TestCase):
def test_istype(self):
self.assertIsInstance(ET.ParseError, type)
self.assertIsInstance(ET.QName, type)
@@ -1879,7 +1886,6 @@ class ElementTreeTest(unittest.TestCase):
class TreeBuilderTest(unittest.TestCase):
-
sample1 = ('<!DOCTYPE html PUBLIC'
' "-//W3C//DTD XHTML 1.0 Transitional//EN"'
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
@@ -1931,7 +1937,6 @@ class TreeBuilderTest(unittest.TestCase):
class NoAcceleratorTest(unittest.TestCase):
-
# Test that the C accelerator was not imported for pyET
def test_correct_import_pyET(self):
self.assertEqual(pyET.Element.__module__, 'xml.etree.ElementTree')
@@ -2096,6 +2101,7 @@ def test_main(module=pyET):
test_classes = [
ElementSlicingTest,
+ BasicElementTest,
StringIOTest,
ParseErrorTest,
ElementTreeTest,