diff --git a/roundup/anypy/xmlrpc_.py b/roundup/anypy/xmlrpc_.py index 9d39e2e0..d77d2341 100644 --- a/roundup/anypy/xmlrpc_.py +++ b/roundup/anypy/xmlrpc_.py @@ -3,18 +3,19 @@ from xmlrpc import client, server # If client.defusedxml == False, client.py will warn that # xmlrpc is insecure and defusedxml should be installed. - client.defusedxml=False + client.defusedxml = False try: from defusedxml import xmlrpc xmlrpc.monkey_patch() # figure out how to allow user to set xmlrpc.MAX_DATA = bytes - client.defusedxml=True + client.defusedxml = True except ImportError: # use regular xmlrpc with warnings pass - server.SimpleXMLRPCDispatcher + server.SimpleXMLRPCDispatcher # noqa: B018 except (ImportError, AttributeError): # Python 2. import SimpleXMLRPCServer as server import xmlrpclib as client # noqa: F401 + client.defusedxml = False diff --git a/test/test_xmlrpc.py b/test/test_xmlrpc.py index ae134689..c3709bf8 100644 --- a/test/test_xmlrpc.py +++ b/test/test_xmlrpc.py @@ -35,6 +35,13 @@ skip_defusedxml_used = lambda func, *args, **kwargs: func +if sys.version_info[0] > 2: + skip_python2 = lambda func, *args, **kwargs: func +else: + skip_python2 = mark_class(pytest.mark.skip( + reason='Skipping test under python 2')) + + class XmlrpcTest(object): backend = None @@ -327,10 +334,12 @@ class S: for n, r in enumerate(result): self.assertEqual(r, results[n]) + @skip_python2 @skip_defusedxml def testDefusedXmlBomb(self): self.XmlBomb(expectIn=b"defusedxml.common.EntitiesForbidden") + @skip_python2 @skip_defusedxml_used def testNonDefusedXmlBomb(self): self.XmlBomb(expectIn=b"1234567890"*511)