gh-130149: cleanup refactorization of `test_hmac.py` by picnixz · Pull Request #131318 · python/cpython · GitHub
Skip to content

gh-130149: cleanup refactorization of test_hmac.py - #131318

Merged
picnixz merged 12 commits into
python:mainfrom
picnixz:feat/test/hmac-130149
Mar 17, 2025
Merged

gh-130149: cleanup refactorization of test_hmac.py#131318
picnixz merged 12 commits into
python:mainfrom
picnixz:feat/test/hmac-130149

Conversation

@picnixz

@picnixz picnixz commented Mar 16, 2025

Copy link
Copy Markdown
Member

Backporting some changes from #130157 so that I don't need to put them out there.

picnixz added 9 commits March 16, 2025 11:48
- add `requires_builtin_hmac` to check if built-in HMAC is available
- refactor `requires_hashdigest` in prevision of a future
  `requires_builtin_hashdigest` for built-in hashes only
- update comments for `CreatorMixin.hmac_new()`
- update comments for `DigestMixin.hmac_digest()`
- update comments for `TestVectorsMixin`
- update comments for `TestVectorsMixin.hmac_new_by_name()`
- update comments for `TestVectorsMixin.hmac_digest_by_name()`
* `assert_hmac_hexdigest_by_new` -> `assert_hmac_hexdigest_by_name`
* use a single function for checking the hexdigest.
@picnixz

This comment was marked as outdated.

@bedevere-bot

This comment was marked as outdated.

@picnixz
picnixz force-pushed the feat/test/hmac-130149 branch from 89eadce to 3ea207e Compare March 16, 2025 11:08
@picnixz

This comment was marked as outdated.

@bedevere-bot

This comment was marked as resolved.

@picnixz

picnixz commented Mar 16, 2025

Copy link
Copy Markdown
Member Author

@picnixz picnixz self-assigned this Mar 16, 2025
Comment thread Lib/test/test_hmac.py
Comment thread Lib/test/support/hashlib_helper.py Outdated
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
@picnixz
picnixz merged commit de8890f into python:main Mar 17, 2025
@picnixz
picnixz deleted the feat/test/hmac-130149 branch March 17, 2025 10:10
plashchynski pushed a commit to plashchynski/cpython that referenced this pull request Mar 17, 2025
…1318)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants