Repository navigation
Move pytest and coverage settings into pyproject.toml - #1551
Conversation
Move pytest.ini into [tool.pytest], keeping its comment, and .coveragerc into [tool.coverage.run], then delete both files. [tool.pytest] is only read by pytest 9 and later. Older versions ignore it without a warning, which would silently stop treating warnings as errors, so require pytest>=9 in tox and in the CONTRIBUTING setup step. Also drop pytest.ini from the CodSpeed workflow paths (pyproject.toml is already listed) and update the comments in tox.ini and CONTRIBUTING.rst that pointed at pytest.ini. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1551 +/- ##
=======================================
Coverage 99.18% 99.18%
=======================================
Files 239 239
Lines 4052 4052
=======================================
Hits 4019 4019
Misses 33 33 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| # Warnings are errors: warning-class problems have repeatedly reached users | ||
| # instead of CI (#1246, #1013, #506). The suite emits no warnings at all today. | ||
| # When an upstream deprecation turns the suite red, fix it if it comes from | ||
| # dateparser, and otherwise add the narrowest possible ignore *after* `error`, | ||
| # since the last matching filter wins. | ||
| # | ||
| # The exemptions below are environmental, not code: tzlocal warns when the host | ||
| # has no usable time zone configuration or a stale one, which CI never sees | ||
| # because it always sets TZ, and pytest warns when it cannot write its cache. |
There was a problem hiding this comment.
I know it is pre-existing text, but this may be a good chance for some trimming.
| # Warnings are errors: warning-class problems have repeatedly reached users | |
| # instead of CI (#1246, #1013, #506). The suite emits no warnings at all today. | |
| # When an upstream deprecation turns the suite red, fix it if it comes from | |
| # dateparser, and otherwise add the narrowest possible ignore *after* `error`, | |
| # since the last matching filter wins. | |
| # | |
| # The exemptions below are environmental, not code: tzlocal warns when the host | |
| # has no usable time zone configuration or a stale one, which CI never sees | |
| # because it always sets TZ, and pytest warns when it cannot write its cache. | |
| # Add ignores after "error": the last matching filter wins. The ones below are | |
| # environmental: tzlocal warns when the host has no usable or a stale time zone | |
| # configuration (CI always sets TZ), and pytest warns when it cannot write its | |
| # cache. |
serhii73
left a comment
There was a problem hiding this comment.
Checked the diff and CI (20/20 green, including min and min-all on Python 3.10, docs, twinecheck and pre-commit). I searched master for leftover references to the deleted files: pytest.ini appears only in CONTRIBUTING.rst, tox.ini and the CodSpeed trigger paths, all updated here, and nothing else (MANIFEST.in, other workflows) mentions pytest.ini or .coveragerc. The moved settings are equivalent to the old files. Approving.
Non-urgent notes:
[tool.pytest]is read only by pytest 9+. With an older pytest (an existing virtualenv, a distro package, or a packager running the tests from the sdist) the warnings-as-errors filter andtestpathsare silently ignored.[tool.pytest.ini_options]is read by every pytest since 6 and would avoid the new floor, if that matters to you.- The
pytest>=9floor is enforced only through the tox deps and the CONTRIBUTING install line, so nothing fails early on an older pytest. [tool.coverage.run]needs TOML support on Python 3.10 (coverage[toml]ortomli). It works here because pytest 9 pulls intomlithere, as the PR notes, and theminenvironments are green.- Three
tox.inicomments no longer name the file; pointing to[tool.pytest]inpyproject.tomlwould keep them actionable.
Summary
Moves
pytest.iniinto[tool.pytest](keeping its comment) and.coveragercinto[tool.coverage.run]inpyproject.toml, and deletes both files.Notes
[tool.pytest]is only read by pytest 9+. Older versions ignore it silently, so warnings would stop being errors. tox now requirespytest>=9, and the CONTRIBUTING setup step installs it.pytest.inifrom the CodSpeed workflow trigger paths (pyproject.tomlis already there), and updated the comments intox.iniandCONTRIBUTING.rstthat referred topytest.ini.Test plan
UserWarningand aDeprecationWarningfails on bothmasterand this branch, and the tzlocal exemption still passes. pytest reportsconfigfile: pyproject.toml. With pytest 8 the same probe passes, which is why the floor is needed.pytestcollects 25,187 tests on both branches (testpaths).coverage debug configshowssource: dateparser, coming frompyproject.toml.tox -e py312,scripts,benchmark,pre-commit,twinecheck,docs: all pass.minpins (withoutatheris, which does not build on macOS):pytestandcoverageboth readpyproject.tomlviatomli, and the full suite passes.🤖 Generated with Claude Code