summaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2019-04-14 10:57:12 +0200
committerChristian Heimes <christian@python.org>2019-04-14 11:45:26 +0200
commit454e17f51b905574ce9fa1a9c112a5f5850d83fe (patch)
tree32c4da6a80355d6b40892758e703cd95e298fa83 /tests.py
parent44586bdd49b04e0b600321e66db135ca1d0a914e (diff)
downloaddefusedxml-git-454e17f51b905574ce9fa1a9c112a5f5850d83fe.tar.gz
Deprecate html argument from Parsers
The defused XMLParse subclass no longer passes the html argument down to the XMLParse class. The argument has been deprecated and ignored for a long time. The DefusedXMLParser still takes a html argument. A deprecation warning is issued when the argument is False and a TypeError when it's True. Fixes: https://github.com/tiran/defusedxml/issues/34 Co-authored-by: Erik Cederstrand <erik@cederstrand.dk> Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'tests.py')
-rw-r--r--tests.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests.py b/tests.py
index 145172c..a769ac8 100644
--- a/tests.py
+++ b/tests.py
@@ -1,8 +1,10 @@
from __future__ import print_function
+
+import io
import os
import sys
import unittest
-import io
+import warnings
from xml.sax.saxutils import XMLGenerator
from xml.sax import SAXParseException
@@ -30,6 +32,12 @@ except ImportError:
LXML3 = False
+warnings.filterwarnings(
+ 'error',
+ category=DeprecationWarning,
+ module=r"defusedxml\..*"
+)
+
HERE = os.path.dirname(os.path.abspath(__file__))
# prevent web access
@@ -186,6 +194,12 @@ class TestDefusedElementTree(BaseTests):
def iterparse(self, source, **kwargs):
return list(self.module.iterparse(source, **kwargs))
+ def test_html_arg(self):
+ with self.assertRaises(DeprecationWarning):
+ ElementTree.XMLParse(html=0)
+ with self.assertRaises(TypeError):
+ ElementTree.XMLParse(html=1)
+
class TestDefusedcElementTree(TestDefusedElementTree):
module = cElementTree