gh-92123: Convert _elementtree types to heap types (#99221)

This commit is contained in:
Erlend E. Aasland 2023-01-20 12:40:06 +01:00 committed by GitHub
parent 9109d46051
commit 3847a6c64b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 185 additions and 236 deletions

View file

@ -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):