]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-130149: cleanup refactorization of `test_hmac.py` (#131318)
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Mon, 17 Mar 2025 10:10:03 +0000 (11:10 +0100)
committerGitHub <noreply@github.com>
Mon, 17 Mar 2025 10:10:03 +0000 (11:10 +0100)
commitde8890f5ab1c1e767029d46c20f513beefc47b18
treee1e33cc3247e57c099a2c61f463e7e65efb9ec1e
parent85c04f80fd3a3098674f60038f248c076a476acf
gh-130149: cleanup refactorization of `test_hmac.py` (#131318)

New features:

* refactor `hashlib_helper.requires_hashdigest` in prevision of a future
  `hashlib_helper.requires_builtin_hashdigest` for built-in hashes only
* add `hashlib_helper.requires_openssl_hashdigest` to request OpenSSL
   hashes, assuming that `_hashlib` exists.

Refactoring:

* split hmac.copy() test by implementation
* update how algorithms are discovered for RFC test cases
* simplify how OpenSSL hash digests are requested
* refactor hexdigest tests for RFC test vectors
* typo fix: `assert_hmac_hexdigest_by_new` -> `assert_hmac_hexdigest_by_name`

Improvements:

* strengthen contract on `hmac_new_by_name` and `hmac_digest_by_name`
* rename mixin classes to better match their responsibility
Lib/hmac.py
Lib/test/support/hashlib_helper.py
Lib/test/test_hmac.py