diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-06-30 17:27:56 +0200 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-06-30 17:27:56 +0200 |
commit | 24ef3e967f4698da6c85778408e920f6437ed344 (patch) | |
tree | ec35aa2c1aa347abbc4bc4f0ba5ab6e668a8856a /Lib/test/test_hmac.py | |
parent | 9c7817e9ee0c6d8909a168ba9e12e87d9e7d6caf (diff) | |
download | cpython-git-24ef3e967f4698da6c85778408e920f6437ed344.tar.gz |
Issue #15225: improve error message when hmac is passed a wrong key type.
Patch by Marc Abramowitz.
Diffstat (limited to 'Lib/test/test_hmac.py')
-rw-r--r-- | Lib/test/test_hmac.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py index 11cacb4d03..4ca7cec44c 100644 --- a/Lib/test/test_hmac.py +++ b/Lib/test/test_hmac.py @@ -234,6 +234,18 @@ class ConstructorTestCase(unittest.TestCase): except: self.fail("Standard constructor call raised exception.") + def test_with_str_key(self): + # Pass a key of type str, which is an error, because it expects a key + # of type bytes + with self.assertRaises(TypeError): + h = hmac.HMAC("key") + + def test_dot_new_with_str_key(self): + # Pass a key of type str, which is an error, because it expects a key + # of type bytes + with self.assertRaises(TypeError): + h = hmac.new("key") + def test_withtext(self): # Constructor call with text. try: |