aboutsummaryrefslogtreecommitdiffstats
path: root/community/py3-twisted/fix-test-suite-python38.patch
diff options
context:
space:
mode:
authorKevin Daudt <kdaudt@alpinelinux.org>2019-11-06 22:20:47 +0000
committerKevin Daudt <kdaudt@alpinelinux.org>2019-11-08 08:35:40 +0000
commit450e40ca331bb6953e36a33bbea53c13a2e03cd0 (patch)
tree9440b111670834bf9090962542a4519d35e5b70d /community/py3-twisted/fix-test-suite-python38.patch
parentcfee5e41793f6a414bae3a98eb3f57e764142ecb (diff)
downloadaports-450e40ca331bb6953e36a33bbea53c13a2e03cd0.tar.bz2
aports-450e40ca331bb6953e36a33bbea53c13a2e03cd0.tar.xz
community/py3-twisted: fix issues with test suite
The test suite was disabled because the python 3.8 upgrade introduced some test failures due to changes. Fix those: * hmac.HMAC now requires a `moddigest` argument * cgi.parse_qs has been removed, urrlib.parse.parse_qs is used instead * cryptography and bcrypt seem to be required for the test suite.
Diffstat (limited to 'community/py3-twisted/fix-test-suite-python38.patch')
-rw-r--r--community/py3-twisted/fix-test-suite-python38.patch138
1 files changed, 138 insertions, 0 deletions
diff --git a/community/py3-twisted/fix-test-suite-python38.patch b/community/py3-twisted/fix-test-suite-python38.patch
new file mode 100644
index 0000000000..89faa9640b
--- /dev/null
+++ b/community/py3-twisted/fix-test-suite-python38.patch
@@ -0,0 +1,138 @@
+Fix test failures that happen due to changes in python 3.8
+
+diff --git a/src/twisted/cred/credentials.py b/src/twisted/cred/credentials.py
+index b55985b6cd..429706ccc7 100644
+--- a/src/twisted/cred/credentials.py
++++ b/src/twisted/cred/credentials.py
+@@ -439,7 +439,7 @@ class CramMD5Credentials(object):
+
+
+ def checkPassword(self, password):
+- verify = hexlify(hmac.HMAC(password, self.challenge).digest())
++ verify = hexlify(hmac.HMAC(password, self.challenge, 'md5').digest())
+ return verify == self.response
+
+
+diff --git a/src/twisted/mail/_cred.py b/src/twisted/mail/_cred.py
+index 9d3646948f..1be9fb2976 100644
+--- a/src/twisted/mail/_cred.py
++++ b/src/twisted/mail/_cred.py
+@@ -28,7 +28,7 @@ class CramMD5ClientAuthenticator:
+
+
+ def challengeResponse(self, secret, chal):
+- response = hmac.HMAC(secret, chal).hexdigest().encode('ascii')
++ response = hmac.HMAC(secret, chal, 'md5').hexdigest().encode('ascii')
+ return self.user + b' ' + response
+
+
+diff --git a/src/twisted/mail/test/test_pop3.py b/src/twisted/mail/test/test_pop3.py
+index 6eb7ecb287..a9895b192f 100644
+--- a/src/twisted/mail/test/test_pop3.py
++++ b/src/twisted/mail/test/test_pop3.py
+@@ -939,7 +939,7 @@ class SASLTests(unittest.TestCase):
+ p.lineReceived(b"AUTH CRAM-MD5")
+ chal = s.getvalue().splitlines()[-1][2:]
+ chal = base64.decodestring(chal)
+- response = hmac.HMAC(b'testpassword', chal).hexdigest().encode("ascii")
++ response = hmac.HMAC(b'testpassword', chal, 'md5').hexdigest().encode("ascii")
+
+ p.lineReceived(
+ base64.encodestring(b'testuser ' + response).rstrip(b'\n'))
+diff --git a/src/twisted/cred/test/test_cramauth.py b/src/twisted/cred/test/test_cramauth.py
+index 1ee08712b6..6db48da3b1 100644
+--- a/src/twisted/cred/test/test_cramauth.py
++++ b/src/twisted/cred/test/test_cramauth.py
+@@ -39,7 +39,7 @@ class CramMD5CredentialsTests(TestCase):
+ """
+ c = CramMD5Credentials()
+ chal = c.getChallenge()
+- c.response = hexlify(HMAC(b'secret', chal).digest())
++ c.response = hexlify(HMAC(b'secret', chal, 'md5').digest())
+ self.assertTrue(c.checkPassword(b'secret'))
+
+
+@@ -61,7 +61,7 @@ class CramMD5CredentialsTests(TestCase):
+ """
+ c = CramMD5Credentials()
+ chal = c.getChallenge()
+- c.response = hexlify(HMAC(b'thewrongsecret', chal).digest())
++ c.response = hexlify(HMAC(b'thewrongsecret', chal, 'md5').digest())
+ self.assertFalse(c.checkPassword(b'secret'))
+
+
+@@ -75,7 +75,7 @@ class CramMD5CredentialsTests(TestCase):
+ chal = c.getChallenge()
+ c.setResponse(b" ".join(
+ (b"squirrel",
+- hexlify(HMAC(b'supersecret', chal).digest()))))
++ hexlify(HMAC(b'supersecret', chal, 'md5').digest()))))
+ self.assertTrue(c.checkPassword(b'supersecret'))
+ self.assertEqual(c.username, b"squirrel")
+
+diff --git a/src/twisted/web/test/test_http.py b/src/twisted/web/test/test_http.py
+index 6527e799c7..0c9d9b82ba 100644
+--- a/src/twisted/web/test/test_http.py
++++ b/src/twisted/web/test/test_http.py
+@@ -7,7 +7,7 @@ Test HTTP support.
+
+ from __future__ import absolute_import, division
+
+-import random, cgi, base64, calendar
++import random, cgi, urllib.parse, base64, calendar
+
+ try:
+ from urlparse import urlparse, urlunsplit, clear_cache
+@@ -2081,15 +2081,15 @@ Hello,
+ class QueryArgumentsTests(unittest.TestCase):
+ def testParseqs(self):
+ self.assertEqual(
+- cgi.parse_qs(b"a=b&d=c;+=f"),
++ urllib.parse.parse_qs(b"a=b&d=c;+=f"),
+ http.parse_qs(b"a=b&d=c;+=f"))
+ self.assertRaises(
+ ValueError, http.parse_qs, b"blah", strict_parsing=True)
+ self.assertEqual(
+- cgi.parse_qs(b"a=&b=c", keep_blank_values=1),
++ urllib.parse.parse_qs(b"a=&b=c", keep_blank_values=1),
+ http.parse_qs(b"a=&b=c", keep_blank_values=1))
+ self.assertEqual(
+- cgi.parse_qs(b"a=&b=c"),
++ urllib.parse.parse_qs(b"a=&b=c"),
+ http.parse_qs(b"a=&b=c"))
+
+
+diff --git a/src/twisted/conch/test/test_ckeygen.py b/src/twisted/conch/test/test_ckeygen.py
+index a8400857c7..257ec99855 100644
+--- a/src/twisted/conch/test/test_ckeygen.py
++++ b/src/twisted/conch/test/test_ckeygen.py
+@@ -89,13 +89,14 @@ class KeyGenTests(TestCase):
+ self._testrun('rsa', '2048')
+ self._testrun('rsa')
+
+-
++ test_keygeneration.skip = "ckeygen binary not available"
+
+ def test_runBadKeytype(self):
+ filename = self.mktemp()
+ with self.assertRaises(subprocess.CalledProcessError):
+ subprocess.check_call(['ckeygen', '-t', 'foo', '-f', filename])
+
++ test_runBadKeytype.skip = "ckeygen binary not available"
+
+
+ def test_enumrepresentation(self):
+diff --git a/src/twisted/words/xish/domish.py b/src/twisted/words/xish/domish.py
+index 2063c410a3..e264b11e16 100644
+--- a/src/twisted/words/xish/domish.py
++++ b/src/twisted/words/xish/domish.py
+@@ -807,7 +807,8 @@ class ExpatElementStream:
+ qname = ('', name)
+
+ # Process attributes
+- for k, v in attrs.items():
++ _attrs = dict(attrs)
++ for k, v in _attrs.items():
+ if " " in k:
+ aqname = k.rsplit(" ", 1)
+ attrs[(aqname[0], aqname[1])] = v