Skip to content

Commit 16800af

Browse files
committed
test: update to handle crypt not available
crypt is not supported in 3.13 and newer. Update test using crypt to work.
1 parent b1c8e53 commit 16800af

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

test/test_hypothesis.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# ruff: noqa: I001 - yes I know I am using \ to continue the line...
1313
from roundup.password import PasswordValueError, encodePassword, \
1414
h64decode, h64encode
15-
15+
from roundup.password import crypt as crypt_method
1616

1717
def Identity(x):
1818
return x
@@ -57,11 +57,15 @@ def test_h64encode_h64decode(self, s):
5757
@settings(max_examples=_max_examples)
5858
def test_encodePassword(self, password, scheme):
5959

60-
if scheme == "crypt" and password and "\x00" in password:
60+
if scheme == "crypt" and password and "\x00" in password:
6161
with self.assertRaises(ValueError) as e:
6262
encodePassword(password, scheme)
63-
self.assertEqual(e.exception.args[0],
64-
"embedded null character")
63+
if crypt_method:
64+
self.assertEqual(e.exception.args[0],
65+
"embedded null character")
66+
else:
67+
self.assertEqual(e.exception.args[0],
68+
"Unsupported encryption scheme 'crypt'")
6569
elif scheme == "plaintext":
6670
if password is not None:
6771
self.assertEqual(encodePassword(password, scheme), password)
@@ -90,7 +94,9 @@ def test_encodePassword(self, password, scheme):
9094
# d41d8cd98f00b204e9800998ecf8427e'
9195
self.assertRegex(pw, r"^[a-z0-9]{32}$")
9296
elif scheme == "crypt":
93-
# WqzFDzhi8MmoU
94-
self.assertRegex(pw, r"^[A-Za-z0-9./]{13}$")
97+
# crypt_method is None if crypt is unknown
98+
if crypt_method:
99+
# WqzFDzhi8MmoU
100+
self.assertRegex(pw, r"^[A-Za-z0-9./]{13}$")
95101
else:
96102
self.assertFalse("Unknown scheme: %s, val: %s" % (scheme, pw))

0 commit comments

Comments
 (0)