summaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2019-04-14 12:35:50 +0200
committerChristian Heimes <christian@python.org>2019-04-14 13:38:12 +0200
commitd1260ab35e53dbb16417f4f6736ab2981f13ddab (patch)
tree05687af9cfa495b4d8a5230c56b3e9d39935a3fe /tests.py
parent94d3be2d43eddc016ebeb813299bcca0484ca2be (diff)
downloaddefusedxml-git-d1260ab35e53dbb16417f4f6736ab2981f13ddab.tar.gz
deprecate defusedxml.lxml
Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'tests.py')
-rw-r--r--tests.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests.py b/tests.py
index 25429c2..22239d7 100644
--- a/tests.py
+++ b/tests.py
@@ -22,14 +22,24 @@ try:
except ImportError:
gzip = None
+
+if sys.version_info < (3, 7):
+ warnings.filterwarnings(
+ 'once',
+ category=DeprecationWarning
+ )
+
+
try:
- from defusedxml import lxml
+ with warnings.catch_warnings(record=True) as lxml_warnings:
+ from defusedxml import lxml
from lxml.etree import XMLSyntaxError
LXML3 = lxml.LXML3
except ImportError:
lxml = None
XMLSyntaxError = None
LXML3 = False
+ lxml_warnings = None
warnings.filterwarnings(
@@ -38,6 +48,7 @@ warnings.filterwarnings(
module=r"defusedxml\..*"
)
+
HERE = os.path.dirname(os.path.abspath(__file__))
# prevent web access
@@ -390,6 +401,11 @@ class TestDefusedLxml(BaseTests):
self.assertEqual(len(elements), 1)
self.assertEqual(elements, list(root)[:1])
+ def test_lxml_warnings(self):
+ self.assertTrue(lxml_warnings)
+ self.assertEqual(lxml_warnings[0].category, DeprecationWarning)
+ self.assertIn('tests.py', lxml_warnings[0].filename)
+
class XmlRpcTarget(object):