diff options
author | Christian Heimes <christian@python.org> | 2020-04-03 16:45:18 +0200 |
---|---|---|
committer | Christian Heimes <christian@python.org> | 2020-04-15 14:06:08 +0200 |
commit | 4339aeea22a90eb48cf2558beaae20ad06e28fbb (patch) | |
tree | f0df47554e6e66cc6fbb142bd4bc182672d0ee41 /tests.py | |
parent | f8e3fe87aee928224378acee5761df3ca6d95dd2 (diff) | |
download | defusedxml-git-4339aeea22a90eb48cf2558beaae20ad06e28fbb.tar.gz |
Python 3.9 compatibility
Python 3.9 no longer ships the xml.etree.cElementTree module. defusedxml
no longer provides the a fixed module with 3.9 as well.
defusedxml.cElementTree is still available with 3.8.
See: https://bugs.python.org/issue36543
See: https://github.com/python/cpython/pull/19108
Fixes: https://github.com/tiran/defusedxml/issues/50
Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'tests.py')
-rw-r--r-- | tests.py | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -10,7 +10,7 @@ from xml.sax.saxutils import XMLGenerator from xml.sax import SAXParseException from pyexpat import ExpatError -from defusedxml import cElementTree, ElementTree, minidom, pulldom, sax, xmlrpc, expatreader +from defusedxml import ElementTree, minidom, pulldom, sax, xmlrpc, expatreader from defusedxml import defuse_stdlib from defusedxml import ( DTDForbidden, @@ -18,7 +18,13 @@ from defusedxml import ( ExternalReferenceForbidden, NotSupportedError, ) -from defusedxml.common import PY3 +from defusedxml.common import PY3, _HAVE_CELEMENTTREE + + +if _HAVE_CELEMENTTREE: + from defusedxml import cElementTree +else: + cElementTree = None try: @@ -205,6 +211,7 @@ class TestDefusedElementTree(BaseTests): assert self.module.XMLParse is parser +@unittest.skipUnless(_HAVE_CELEMENTTREE, "Python 3.9 has removed cElementTree") class TestDefusedcElementTree(TestDefusedElementTree): module = cElementTree |