summaryrefslogtreecommitdiff
path: root/passlib/tests
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2020-10-05 21:26:25 -0400
committerEli Collins <elic@assurancetechnologies.com>2020-10-05 21:26:25 -0400
commit6badf316805b188c92165e342ca88ce3be9a96db (patch)
tree735fe346eb1140c858fc3e57a08ac3eb5292905d /passlib/tests
parent3f1ad211d9499f5c36e9cc90c888c6e0da50ab3c (diff)
downloadpasslib-6badf316805b188c92165e342ca88ce3be9a96db.tar.gz
passlib.utils: add thread lock to fix some UT failures.
Diffstat (limited to 'passlib/tests')
-rw-r--r--passlib/tests/utils.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/passlib/tests/utils.py b/passlib/tests/utils.py
index a698ac7..c8ab5a4 100644
--- a/passlib/tests/utils.py
+++ b/passlib/tests/utils.py
@@ -2728,7 +2728,9 @@ class HandlerCase(TestCase):
failed[0] += 1
raise
def launch(n):
- name = "Fuzz-Thread-%d" % (n,)
+ cls = type(self)
+ name = "Fuzz-Thread-%d ('%s:%s.%s')" % (n, cls.__module__, cls.__name__,
+ self._testMethodName)
thread = threading.Thread(target=wrapper, name=name)
thread.setDaemon(True)
thread.start()
@@ -3313,8 +3315,9 @@ class OsCryptMixin(HandlerCase):
(platform, name))
#===================================================================
- # fuzzy verified support -- add new verified that uses os crypt()
+ # fuzzy verified support -- add additional verifier that uses os crypt()
#===================================================================
+
def fuzz_verifier_crypt(self):
"""test results against OS crypt()"""
@@ -3326,14 +3329,17 @@ class OsCryptMixin(HandlerCase):
# create a wrapper for fuzzy verified to use
from crypt import crypt
+ from passlib.utils import _safe_crypt_lock
encoding = self.FuzzHashGenerator.password_encoding
def check_crypt(secret, hash):
"""stdlib-crypt"""
if not self.crypt_supports_variant(hash):
return "skip"
+ # XXX: any reason not to use safe_crypt() here? or just want to test against bare metal?
secret = to_native_str(secret, encoding)
- return crypt(secret, hash) == hash
+ with _safe_crypt_lock:
+ return crypt(secret, hash) == hash
return check_crypt