summaryrefslogtreecommitdiff
path: root/Lib/test/test_xml_etree.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_xml_etree.py')
-rw-r--r--Lib/test/test_xml_etree.py42
1 files changed, 22 insertions, 20 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 61416ba7c6..8b16905087 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1795,6 +1795,28 @@ class BasicElementTest(ElementTestCase, unittest.TestCase):
self.assertRaises(TypeError, e.append, 'b')
self.assertRaises(TypeError, e.extend, [ET.Element('bar'), 'foo'])
self.assertRaises(TypeError, e.insert, 0, 'foo')
+ e[:] = [ET.Element('bar')]
+ with self.assertRaises(TypeError):
+ e[0] = 'foo'
+ with self.assertRaises(TypeError):
+ e[:] = [ET.Element('bar'), 'foo']
+
+ if hasattr(e, '__setstate__'):
+ state = {
+ 'tag': 'tag',
+ '_children': [None], # non-Element
+ 'attrib': 'attr',
+ 'tail': 'tail',
+ 'text': 'text',
+ }
+ self.assertRaises(TypeError, e.__setstate__, state)
+
+ if hasattr(e, '__deepcopy__'):
+ class E(ET.Element):
+ def __deepcopy__(self, memo):
+ return None # non-Element
+ e[:] = [E('bar')]
+ self.assertRaises(TypeError, copy.deepcopy, e)
def test_cyclic_gc(self):
class Dummy:
@@ -1981,26 +2003,6 @@ class BadElementTest(ElementTestCase, unittest.TestCase):
elem = b.close()
self.assertEqual(elem[0].tail, 'ABCDEFGHIJKL')
- def test_element_iter(self):
- # Issue #27863
- state = {
- 'tag': 'tag',
- '_children': [None], # non-Element
- 'attrib': 'attr',
- 'tail': 'tail',
- 'text': 'text',
- }
-
- e = ET.Element('tag')
- try:
- e.__setstate__(state)
- except AttributeError:
- e.__dict__ = state
-
- it = e.iter()
- self.assertIs(next(it), e)
- self.assertRaises(AttributeError, next, it)
-
def test_subscr(self):
# Issue #27863
class X: