Skip to content

Commit fb7e577

Browse files
committed
extend coverage
1 parent c04233d commit fb7e577

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

Lib/test/test_hmac.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def assert_hmac(
159159
self.assert_hmac_digest(
160160
key, msg, digest, digestmod, digest_size
161161
)
162-
self.assert_hmac_cases(
162+
self.assert_hmac_extra_cases(
163163
key, msg, digest, digestmod,
164164
hashname, digest_size, block_size
165165
)
@@ -208,11 +208,6 @@ def hmac_new_feed(*args):
208208
with self.subTest('initial message is None'):
209209
hmac_new_feed(None)
210210

211-
def assert_hmac_cases(
212-
self, key, msg, digest, hashimpl, hashname, digest_size, block_size
213-
):
214-
"""Extra tests that can be added in subclasses."""
215-
216211
def assert_hmac_digest(
217212
self, key, msg, digest, digestmod, digest_size,
218213
):
@@ -228,18 +223,26 @@ def assert_hmac_digest_by_new(
228223
self.assertEqual(len(d), digest_size)
229224
self.assertEqual(d, binascii.unhexlify(digest))
230225

231-
232-
class PyTestVectorsMixin(PyModuleMixin, TestVectorsMixin):
233-
234-
def assert_hmac_cases(
226+
def assert_hmac_extra_cases(
235227
self, key, msg, digest, digestmod, hashname, digest_size, block_size
236228
):
237-
h1 = self.hmac.HMAC(key, digestmod=digestmod)
229+
"""Extra tests that can be added in subclasses."""
230+
h1 = self.hmac_new(key, digestmod=digestmod)
238231
h2 = h1.copy()
239232
h2.update(b"test update should not affect original")
240233
h1.update(msg)
241234
self.check_object(h1, digest, hashname, digest_size, block_size)
242235

236+
237+
class PyTestVectorsMixin(PyModuleMixin, TestVectorsMixin):
238+
239+
def assert_hmac_extra_cases(
240+
self, key, msg, digest, digestmod, hashname, digest_size, block_size
241+
):
242+
super().assert_hmac_extra_cases(
243+
key, msg, digest, digestmod, hashname, digest_size, block_size
244+
)
245+
243246
h = self.hmac.HMAC.__new__(self.hmac.HMAC)
244247
h._init_old(key, msg, digestmod=digestmod)
245248
self.check_object(h, digest, hashname, digest_size, block_size)

0 commit comments

Comments
 (0)