GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Refactor tests for HMAC · Issue #130149 · python/cpython

Refactor tests for HMAC #130149

New issue
Copy link
New issue
Copy link
Closed
Closed
Refactor tests for HMAC#130149
Copy link
Assignees
picnixz
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-featureA feature request or enhancementA feature request or enhancement

Description

@picnixz
picnixz
opened on Feb 15, 2025
Issue body actions

The tests for HMAC are organized in such a way that makes the adoption of HACL* HMAC harder. More precisely, it'll be a bit harder to test the OpenSSL and the HACL* implementation of HMAC (for instance, some tests may or may not work with HACL* as they only support a subset of the hash functions supported by OpenSSL).

I am suggesting a way to make the test interface more generic using mixin classes. For instance, we have multiple ways of creating a HMAC object. It can be through hmac.HMAC or through hmac.new or through _hashlib.hmac_new. While hmac.new and hmac.HMAC are identical, _hashlib.hmac_new is different in the sense that the signature is different as well (and that the objects being returned are also different; they are not instances of hmac.HMAC but instances of _hashlib.HMAC, though they implement the same interface).

Now, once we add HACL* implementation, the interface will be similar to the Python implementation of HMAC and thus we need to test them both. Currently, it's hard to switch from the Python module implementation to the C implementation.

Linked PRs

  • gh-130149: refactor tests for HMAC #130150
  • gh-130149: fix HMAC tests for some FIPS-only build bots #130788
  • gh-130149: cleanup refactorization of test_hmac.py #131318

Activity

  1. picnixz
    added
    testsTests in the Lib/test dirTests in the Lib/test dir
    type-featureA feature request or enhancementA feature request or enhancement
    on Feb 15, 2025
  2. picnixz
    self-assigned this
    on Feb 15, 2025
  3. picnixz
    added a commit that references this issue on Mar 3, 2025

    gh-130149: refactor tests for HMAC (#130150)

    8f11af4
  4. picnixz
    closed this as completedon Mar 3, 2025
  5. picnixz commented on Mar 3, 2025

    @picnixz
    picnixz
    on Mar 3, 2025
    MemberAuthor
    More actions

    I won't backport this one because there will be too many conflicts. In addition, since we won't have multiple implementations of HMAC on 3.12 and 3.13, there is no need for the mixins.

  6. picnixz
    added a commit that references this issue on Mar 4, 2025

    gh-130149: fix HMAC tests for some FIPS-only build bots (#130788)

    15d926b
  7. picnixz
    reopened this on Mar 16, 2025
  8. picnixz commented on Mar 16, 2025

    @picnixz
    picnixz
    on Mar 16, 2025
    MemberAuthor
    More actions

    I'm re-opening this one as I want to introduce some tweaks I did in #130157 instead of the other PR.

  9. picnixz
    added a commit that references this issue on Mar 17, 2025

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

    de8890f
  10. picnixz
    closed this as completedon Mar 17, 2025
  11. plashchynski
    added a commit that references this issue on Mar 17, 2025

    pythongh-130149: cleanup refactorization of `test_hmac.py` (python#13…

    0cec3dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @picnixz
    picnixz

Labels

testsTests in the Lib/test dirTests in the Lib/test dirtype-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.