Skip to content

Conversation

@JanFSchulte
Copy link
Contributor

As pointed out by @marco66colombo in #1412, pytest 9 enforces a rule that fixtures can't be parametrized. The way around that is indirect parametrization via the calling test function. This PR makes that change for all tests.

Downsides:

  • Nested parametrizations are not supported this way, leading to a bit of overhead in declaring tests.
  • The tests are no longer named using the values of the parameters, so a test will no longer by called test_embedding_accuracy[Catapult, io_parallel] but rather test_embedding_accuracy[hls_model3] for example. This will make it more annoying to identify the failing test.

Type of change

  • Bug fix (non-breaking change that fixes an issue)

Tests

Tested all affected test locally in an environment with pytest 9.

Checklist

  • All

@jmitrevs
Copy link
Contributor

Were the tests working before? The error message suggests that the parametrization was always ignored, and just now it gives an error. My understanding is that it means the tests behaved before as if that line was just deleted.

@JanFSchulte
Copy link
Contributor Author

I think before the lines were ignored, but the parametrization was always repeated for the actual test function. So i think overall the tests were working and the values of the parameters were passed to the fixtures implicitly. Using the indirect parametrization is the more correct way of doing this, though.

@marco66colombo
Copy link
Contributor

It's possible to keep the test case names using ids= also with indirect parametrization.
Example:

@pytest.mark.parametrize(
    "hls_model",
    [
        ("Vivado", "io_parallel"),
        ("Quartus", "io_parallel"),
        ("Vivado", "io_stream"),
    ],
    indirect=True,
    ids=[
        "vivado_parallel",
        "quartus_parallel",
        "vivado_stream",
    ],
)
def test_embedding_accuracy(hls_model):
    ...

This will show names like test_embedding_accuracy[vivado_parallel] instead of hls_model3.

@JanFSchulte
Copy link
Contributor Author

Cool! I added these ids to all affected tests.

Gab-San added a commit to Gab-San/hls4ml-bambu that referenced this pull request Jan 15, 2026
@jmitrevs jmitrevs merged commit ad20aa6 into main Jan 15, 2026
5 checks passed
@jmitrevs jmitrevs deleted the pytest9 branch January 15, 2026 20:15
nghielme added a commit to nghielme/hls4ml that referenced this pull request Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants