Mercurial > p > roundup > code
changeset 8238:05405220dc38
issue2551116 - difusedxml support - python2 fixups.
Make sure python2 code path sets client.defusedxml so the code can
still run.
Bomb tests fail under python2. So disable test under python 2. In the
past it was due to string/byte type difference. Not worth fixing the
tests since python 2 support dropped.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 29 Dec 2024 19:48:42 -0500 |
| parents | 57325fea9982 |
| children | 6bd11a73f2ed |
| files | roundup/anypy/xmlrpc_.py test/test_xmlrpc.py |
| diffstat | 2 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/anypy/xmlrpc_.py Sun Dec 29 19:11:01 2024 -0500 +++ b/roundup/anypy/xmlrpc_.py Sun Dec 29 19:48:42 2024 -0500 @@ -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
--- a/test/test_xmlrpc.py Sun Dec 29 19:11:01 2024 -0500 +++ b/test/test_xmlrpc.py Sun Dec 29 19:48:42 2024 -0500 @@ -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 @@ 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)
