summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_xml_etree_c.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-11-23 06:47:26 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-11-23 06:47:26 (GMT)
commit3987fefd6f7309a36fb093cbfe229afe7b39406b (patch)
treee57eab9c07cc1c34906dee5e0f34cbe58c21a93f /Lib/test/test_xml_etree_c.py
parent21cecb904f80a53a23dc972c95cb0c4c997afbe1 (diff)
parentb6aa5375d5a2f81370338357506034befe62aa31 (diff)
downloadcpython-3987fefd6f7309a36fb093cbfe229afe7b39406b.zip
cpython-3987fefd6f7309a36fb093cbfe229afe7b39406b.tar.gz
cpython-3987fefd6f7309a36fb093cbfe229afe7b39406b.tar.bz2
Issue #25691: Fixed crash on deleting ElementTree.Element attributes.
Diffstat (limited to 'Lib/test/test_xml_etree_c.py')
-rw-r--r--Lib/test/test_xml_etree_c.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py
index d0df38d..96b446e 100644
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -22,6 +22,38 @@ class MiscTests(unittest.TestCase):
finally:
data = None
+ def test_del_attribute(self):
+ element = cET.Element('tag')
+
+ element.tag = 'TAG'
+ with self.assertRaises(AttributeError):
+ del element.tag
+ self.assertEqual(element.tag, 'TAG')
+
+ with self.assertRaises(AttributeError):
+ del element.text
+ self.assertIsNone(element.text)
+ element.text = 'TEXT'
+ with self.assertRaises(AttributeError):
+ del element.text
+ self.assertEqual(element.text, 'TEXT')
+
+ with self.assertRaises(AttributeError):
+ del element.tail
+ self.assertIsNone(element.tail)
+ element.tail = 'TAIL'
+ with self.assertRaises(AttributeError):
+ del element.tail
+ self.assertEqual(element.tail, 'TAIL')
+
+ with self.assertRaises(AttributeError):
+ del element.attrib
+ self.assertEqual(element.attrib, {})
+ element.attrib = {'A': 'B', 'C': 'D'}
+ with self.assertRaises(AttributeError):
+ del element.attrib
+ self.assertEqual(element.attrib, {'A': 'B', 'C': 'D'})
+
@unittest.skipUnless(cET, 'requires _elementtree')
class TestAliasWorking(unittest.TestCase):