summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_xml_etree_c.py
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend.aasland@protonmail.com>2023-01-20 11:40:06 (GMT)
committerGitHub <noreply@github.com>2023-01-20 11:40:06 (GMT)
commit3847a6c64b96bb2cb93be394a590d4df2c35e876 (patch)
tree690f476a3bbd8f850e524b9a46ecd626f39f5ec8 /Lib/test/test_xml_etree_c.py
parent9109d460511a317f5598a26658ba495e77ea8686 (diff)
downloadcpython-3847a6c64b96bb2cb93be394a590d4df2c35e876.zip
cpython-3847a6c64b96bb2cb93be394a590d4df2c35e876.tar.gz
cpython-3847a6c64b96bb2cb93be394a590d4df2c35e876.tar.bz2
gh-92123: Convert `_elementtree` types to heap types (#99221)
Diffstat (limited to 'Lib/test/test_xml_etree_c.py')
-rw-r--r--Lib/test/test_xml_etree_c.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py
index bec8208..fd27b57 100644
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -181,6 +181,26 @@ class MiscTests(unittest.TestCase):
r = e.get(X())
self.assertIsNone(r)
+ @support.cpython_only
+ def test_immutable_types(self):
+ root = cET.fromstring('<a></a>')
+ dataset = (
+ cET.Element,
+ cET.TreeBuilder,
+ cET.XMLParser,
+ type(root.iter()),
+ )
+ for tp in dataset:
+ with self.subTest(tp=tp):
+ with self.assertRaisesRegex(TypeError, "immutable"):
+ tp.foo = 1
+
+ @support.cpython_only
+ def test_disallow_instantiation(self):
+ root = cET.fromstring('<a></a>')
+ iter_type = type(root.iter())
+ support.check_disallow_instantiation(self, iter_type)
+
@unittest.skipUnless(cET, 'requires _elementtree')
class TestAliasWorking(unittest.TestCase):