test: Fix some test parametrizations#576
Merged
ValerianRey merged 3 commits intomainfrom Feb 18, 2026
Merged
Conversation
This happens for Weightings, for which we didn't provide a proper repr and str yet. So this fixes test_weighting_output in test_values.py.
Contributor
Author
|
@PierreQuinton FYI, it's now possible to run all tests from VSCode from the testing tab. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some test parametrization had problems, which we didn't see until we started using VSCode's testing tool, that runs each test by providing its exact parametrization string to pytest. For context, the parametrization string is called the
idin the context of pytest, and it can be overridden in thepytest_make_parametrize_idfunction ofconftest.py(which I did a few months ago to make them shorter and more informative).There were two issues:
\nin their id. We didn't define thereprmethod forWeightings yet, so theirreprwas the methodreprinheritted fromnn.Module, which contains a\n. I fixedpytest_make_parametrize_idto replace\nby a space._non_empty_subsets, used to make the parametrization oftest_compute_partial_gramianintest_engine.py, was a list of sets. Since the order of set elements is non-deterministic, VSCode tried to call those tests with a given string (e.g. '{"fc0", "fc1"}), while the collection of pytest created a different possible parametrization (e.g. '{"fc1", "fc0"}'). I fixed this by making_non_empty_subsetsreturn lists instead of sets, and explaining why in the docstring.This also fixes a wrong type hint in
test_weighting_output. I thinktycannot detect typing error in pytest's test parametrizations. I don't think there's an easy fix, unless we install some plugin.