Skip to content

Adopt pytest's strict mode#387

Merged
tpvasconcelos merged 4 commits into
mainfrom
240-pytest-good-practices
Jul 25, 2026
Merged

Adopt pytest's strict mode#387
tpvasconcelos merged 4 commits into
mainfrom
240-pytest-good-practices

Conversation

@tpvasconcelos

@tpvasconcelos tpvasconcelos commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Closes #240

Summary

Went through pytest's Good Integration Practices guide and audited the project against it. Most recommendations were already in place:

  • src layout with tests outside application code
  • --import-mode=importlib (so the test package name / duplicate-basename concerns don't apply — e.g. the two test_init.py modules collect fine without __init__.py files)
  • ✅ tox testing against the built wheel
  • flake8-pytest-style checks (via ruff's select = ["ALL"])

The one remaining gap was pytest's strict mode, added in pytest 9.0. This PR:

  • Enables strict = true in pytest.ini, superseding the previous --strict-markers flag and xfail_strict ini option. This also enables strict_config and strict_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's select = ["ALL"] and filterwarnings = error). If you'd rather not auto-adopt future options, the alternative is to enable the four current strict_* options individually.
  • Adds a pytest>=9 floor to requirements/tests.txt (pytest 9 supports Python >=3.10, matching this project's minimum).
  • Fixes duplicate parametrization IDs surfaced by strict_parametrization_ids in test_hist.py and test_kde.py (np.inf/float("inf") and np.nan/float("nan") generate identical IDs) by adding explicit unique ids=.
  • Fixes test_utils.py passing an itertools.product iterator 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 on main (the PytestRemovedIn10Warning is promoted to an error by filterwarnings = error), independently of this PR.
  • Refreshes the pinned 8.3.x doc links in pytest.ini comments to stable.

Test plan

  • pytest tests/unit --doctest-modules src — 237 passed, 3 xfailed
  • pytest tests/e2e — 5 passed (1 pre-existing local-only failure: test_paths_exist asserts the repo dir is named ridgeplot, which doesn't hold in a worktree checkout; passes on CI)
  • pytest tests/cicd_utils — 24 passed
  • pre-commit hooks (incl. ruff + ruff-format) pass
  • pyright — 0 errors

📚 Documentation preview 📚: https://ridgeplot--387.org.readthedocs.build/en/387/

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.
@github-actions

This comment has been minimized.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9b464c8) to head (6c79423).
⚠️ Report is 11 commits behind head on main.

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           
Flag Coverage Δ
combined-src 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tpvasconcelos
tpvasconcelos merged commit 978b863 into main Jul 25, 2026
12 of 13 checks passed
@tpvasconcelos
tpvasconcelos deleted the 240-pytest-good-practices branch July 25, 2026 03:46
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.

Check pytest's "good practices" guide

1 participant