diff -r 9623c83ba489 Lib/test/test_hmac.py --- a/Lib/test/test_hmac.py Wed Jun 27 15:26:26 2012 -0400 +++ b/Lib/test/test_hmac.py Fri Jun 29 11:49:10 2012 -0700 @@ -234,6 +234,22 @@ 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") + self.fail("Expected TypeError because we passed a str key and it" + " should be bytes") + + 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") + self.fail("Expected TypeError because we passed a str key and it" + " should be bytes") + def test_withtext(self): # Constructor call with text. try: