Adopt pytest's strict mode#387
Merged
Merged
Conversation
Follow the recommendations from pytest's "Good Integration Practices" guide by enabling all of pytest's strictness options (`strict = true`, added in pytest 9.0). This supersedes the previous `--strict-markers` flag and `xfail_strict` ini option, and additionally enables `strict_config` and `strict_parametrization_ids`. Also fix the issues surfaced by the stricter configuration and by pytest 9.1's deprecation of iterator argvalues in parametrize.
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #387 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 18 18
Lines 657 657
Branches 85 85
=========================================
Hits 657 657
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ices # Conflicts: # docs/reference/changelog.md
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.
Closes #240
Summary
Went through pytest's Good Integration Practices guide and audited the project against it. Most recommendations were already in place:
srclayout with tests outside application code--import-mode=importlib(so the test package name / duplicate-basename concerns don't apply — e.g. the twotest_init.pymodules collect fine without__init__.pyfiles)flake8-pytest-stylechecks (via ruff'sselect = ["ALL"])The one remaining gap was pytest's strict mode, added in pytest 9.0. This PR:
strict = trueinpytest.ini, superseding the previous--strict-markersflag andxfail_strictini option. This also enablesstrict_configandstrict_parametrization_ids, and will automatically pick up new strictness options as they are added to pytest (consistent with the project's approach of, e.g., ruff'sselect = ["ALL"]andfilterwarnings = error). If you'd rather not auto-adopt future options, the alternative is to enable the four currentstrict_*options individually.pytest>=9floor torequirements/tests.txt(pytest 9 supports Python >=3.10, matching this project's minimum).strict_parametrization_idsintest_hist.pyandtest_kde.py(np.inf/float("inf")andnp.nan/float("nan")generate identical IDs) by adding explicit uniqueids=.test_utils.pypassing anitertools.productiterator to@pytest.mark.parametrize, which pytest 9.1 deprecates for removal in pytest 10. Note this was already breaking test collection with pytest 9.1.x onmain(thePytestRemovedIn10Warningis promoted to an error byfilterwarnings = error), independently of this PR.8.3.xdoc links inpytest.inicomments tostable.Test plan
pytest tests/unit --doctest-modules src— 237 passed, 3 xfailedpytest tests/e2e— 5 passed (1 pre-existing local-only failure:test_paths_existasserts the repo dir is namedridgeplot, which doesn't hold in a worktree checkout; passes on CI)pytest tests/cicd_utils— 24 passedpre-commithooks (incl. ruff + ruff-format) passpyright— 0 errors📚 Documentation preview 📚: https://ridgeplot--387.org.readthedocs.build/en/387/