@@ -302,45 +302,38 @@ def digest(self):
302302 hmac .HMAC (b'a' , b'b' , digestmod = MockCrazyHash )
303303 self .fail ('Expected warning about small block_size' )
304304
305- def test_with_digestmod_warning (self ):
306- with self .assertWarns ( DeprecationWarning ):
305+ def test_with_digestmod_no_default (self ):
306+ with self .assertRaises ( ValueError ):
307307 key = b"\x0b " * 16
308308 data = b"Hi There"
309- digest = "9294727A3638BB1C13F48EF8158BFC9D"
310- h = hmac .HMAC (key , data )
311- self .assertEqual (h .hexdigest ().upper (), digest )
312-
309+ hmac .HMAC (key , data , digestmod = None )
313310
314311class ConstructorTestCase (unittest .TestCase ):
315312
316- @ignore_warning
317313 def test_normal (self ):
318314 # Standard constructor call.
319315 failed = 0
320316 try :
321- h = hmac .HMAC (b"key" )
317+ h = hmac .HMAC (b"key" , digestmod = 'md5' )
322318 except Exception :
323319 self .fail ("Standard constructor call raised exception." )
324320
325- @ignore_warning
326321 def test_with_str_key (self ):
327322 # Pass a key of type str, which is an error, because it expects a key
328323 # of type bytes
329324 with self .assertRaises (TypeError ):
330- h = hmac .HMAC ("key" )
325+ h = hmac .HMAC ("key" , digestmod = 'md5' )
331326
332- @ignore_warning
333327 def test_dot_new_with_str_key (self ):
334328 # Pass a key of type str, which is an error, because it expects a key
335329 # of type bytes
336330 with self .assertRaises (TypeError ):
337- h = hmac .new ("key" )
331+ h = hmac .new ("key" , digestmod = 'md5' )
338332
339- @ignore_warning
340333 def test_withtext (self ):
341334 # Constructor call with text.
342335 try :
343- h = hmac .HMAC (b"key" , b"hash this!" )
336+ h = hmac .HMAC (b"key" , b"hash this!" , digestmod = 'md5' )
344337 except Exception :
345338 self .fail ("Constructor call with text argument raised exception." )
346339 self .assertEqual (h .hexdigest (), '34325b639da4cfd95735b381e28cb864' )
@@ -369,13 +362,6 @@ def test_withmodule(self):
369362
370363class SanityTestCase (unittest .TestCase ):
371364
372- @ignore_warning
373- def test_default_is_md5 (self ):
374- # Testing if HMAC defaults to MD5 algorithm.
375- # NOTE: this whitebox test depends on the hmac class internals
376- h = hmac .HMAC (b"key" )
377- self .assertEqual (h .digest_cons , hashlib .md5 )
378-
379365 def test_exercise_all_methods (self ):
380366 # Exercising all methods once.
381367 # This must not raise any exceptions
0 commit comments