summaryrefslogtreecommitdiff
path: root/passlib/tests/test_context.py
diff options
context:
space:
mode:
Diffstat (limited to 'passlib/tests/test_context.py')
-rw-r--r--passlib/tests/test_context.py32
1 files changed, 11 insertions, 21 deletions
diff --git a/passlib/tests/test_context.py b/passlib/tests/test_context.py
index ffd37e9..09b52c0 100644
--- a/passlib/tests/test_context.py
+++ b/passlib/tests/test_context.py
@@ -1647,6 +1647,7 @@ sha512_crypt__min_rounds = 45000
#
# init ref info
#
+ from passlib.exc import UnknownHashError
from passlib.hash import md5_crypt, unix_disabled
ctx = CryptContext(["des_crypt"])
@@ -1684,18 +1685,13 @@ sha512_crypt__min_rounds = 45000
# test w/o disabled hash support
self.assertTrue(ctx.is_enabled(h_ref))
- HASH_NOT_IDENTIFIED = "hash could not be identified"
- self.assertRaisesRegex(ValueError, HASH_NOT_IDENTIFIED,
- ctx.is_enabled, h_other)
- self.assertRaisesRegex(ValueError, HASH_NOT_IDENTIFIED,
- ctx.is_enabled, h_dis)
- self.assertRaisesRegex(ValueError, HASH_NOT_IDENTIFIED,
- ctx.is_enabled, h_dis_ref)
+ self.assertRaises(UnknownHashError, ctx.is_enabled, h_other)
+ self.assertRaises(UnknownHashError, ctx.is_enabled, h_dis)
+ self.assertRaises(UnknownHashError, ctx.is_enabled, h_dis_ref)
# test w/ disabled hash support
self.assertTrue(ctx2.is_enabled(h_ref))
- self.assertRaisesRegex(ValueError, HASH_NOT_IDENTIFIED,
- ctx.is_enabled, h_other)
+ self.assertRaises(UnknownHashError, ctx.is_enabled, h_other)
self.assertFalse(ctx2.is_enabled(h_dis))
self.assertFalse(ctx2.is_enabled(h_dis_ref))
@@ -1704,24 +1700,18 @@ sha512_crypt__min_rounds = 45000
#
# test w/o disabled hash support
- self.assertRaisesRegex(ValueError, HASH_NOT_IDENTIFIED,
- ctx.enable, "")
+ self.assertRaises(UnknownHashError, ctx.enable, "")
self.assertRaises(TypeError, ctx.enable, None)
self.assertEqual(ctx.enable(h_ref), h_ref)
- self.assertRaisesRegex(ValueError, HASH_NOT_IDENTIFIED,
- ctx.enable, h_other)
- self.assertRaisesRegex(ValueError, HASH_NOT_IDENTIFIED,
- ctx.enable, h_dis)
- self.assertRaisesRegex(ValueError, HASH_NOT_IDENTIFIED,
- ctx.enable, h_dis_ref)
+ self.assertRaises(UnknownHashError, ctx.enable, h_other)
+ self.assertRaises(UnknownHashError, ctx.enable, h_dis)
+ self.assertRaises(UnknownHashError, ctx.enable, h_dis_ref)
# test w/ disabled hash support
- self.assertRaisesRegex(ValueError, HASH_NOT_IDENTIFIED,
- ctx.enable, "")
+ self.assertRaises(UnknownHashError, ctx.enable, "")
self.assertRaises(TypeError, ctx2.enable, None)
self.assertEqual(ctx2.enable(h_ref), h_ref)
- self.assertRaisesRegex(ValueError, HASH_NOT_IDENTIFIED,
- ctx2.enable, h_other)
+ self.assertRaises(UnknownHashError, ctx2.enable, h_other)
self.assertRaisesRegex(ValueError, "cannot restore original hash",
ctx2.enable, h_dis)
self.assertEqual(ctx2.enable(h_dis_ref), h_ref)