summaryrefslogtreecommitdiff
path: root/passlib/tests
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2012-02-08 22:41:37 -0500
committerEli Collins <elic@assurancetechnologies.com>2012-02-08 22:41:37 -0500
commit098f270258d6991ec0c74b63783cc0fcf3eecab9 (patch)
tree7d13fd1fe3a90b511cfd5eea6861f38059b0dfd9 /passlib/tests
parent86a2dc3ed68fcdf7853f5e219541a19b5fcacfff (diff)
downloadpasslib-098f270258d6991ec0c74b63783cc0fcf3eecab9.tar.gz
minor tweaks & fixes
Diffstat (limited to 'passlib/tests')
-rw-r--r--passlib/tests/test_handlers.py6
-rw-r--r--passlib/tests/utils.py8
2 files changed, 7 insertions, 7 deletions
diff --git a/passlib/tests/test_handlers.py b/passlib/tests/test_handlers.py
index 98a741f..5c94b73 100644
--- a/passlib/tests/test_handlers.py
+++ b/passlib/tests/test_handlers.py
@@ -1373,8 +1373,7 @@ class _SHA256CryptTest(HandlerCase):
"2bIC" ),
]
- def filter_known_config_warnings(self):
- warnings.filterwarnings("ignore", "sha256_crypt does not allow less than 1000 rounds: 10", UserWarning)
+ filter_config_warnings = True # rounds too low, salt too small
def test_raw(self):
#run some tests on raw backend func to ensure it works right
@@ -1447,8 +1446,7 @@ class _SHA512CryptTest(HandlerCase):
"hLsPuWGsUSklZt58jaTfF4ZEQpyUNGc0dqbpBYYBaHHrsX." ),
]
- def filter_known_config_warnings(self):
- warnings.filterwarnings("ignore", "sha512_crypt does not allow less than 1000 rounds: 10", UserWarning)
+ filter_config_warnings = True # rounds too low, salt too small
OsCrypt_SHA512CryptTest = create_backend_case(_SHA512CryptTest, "os_crypt")
Builtin_SHA512CryptTest = create_backend_case(_SHA512CryptTest, "builtin")
diff --git a/passlib/tests/utils.py b/passlib/tests/utils.py
index a89e707..92e601e 100644
--- a/passlib/tests/utils.py
+++ b/passlib/tests/utils.py
@@ -912,17 +912,17 @@ class HandlerCase(TestCase):
#=========================================================
#genhash()
#=========================================================
- filter_known_config_warnings = None
+ filter_config_warnings = False
def test_40_genhash_config(self):
"test genhash() against known config strings"
if not self.known_correct_configs:
raise self.skipTest("no config strings provided")
- fk = self.filter_known_config_warnings
+ fk = self.filter_config_warnings
if fk:
ctx = catch_warnings()
ctx.__enter__()
- fk()
+ warnings.filterwarnings("ignore", category=PasslibHandlerWarning)
for config, secret, hash in self.known_correct_configs:
result = self.do_genhash(secret, config)
self.assertEqual(result, hash, "config=%r,secret=%r:" % (config,secret))
@@ -1022,6 +1022,8 @@ class HandlerCase(TestCase):
# generate a single hash, and verify it using all helpers.
secret = b('t\xc3\xa1\xd0\x91\xe2\x84\x93\xc9\x99').decode("utf-8")
hash = self.do_encrypt(secret)
+ if PY2 and isinstance(secret, unicode):
+ secret = secret.encode("utf-8")
for helper in helpers:
helper(secret, hash)