Skip to content

Move pytest and coverage settings into pyproject.toml - #1551

Merged
serhii73 merged 1 commit into
scrapinghub:masterfrom
hammadqureshi-web:move-pytest-coverage-config
Nov 5, 2026
Merged

serhii73 merged 1 commit into
scrapinghub:masterfrom
hammadqureshi-web:move-pytest-coverage-config

Conversation

@hammadqureshi-web

Copy link
Copy Markdown
Contributor

Summary

Moves pytest.ini into [tool.pytest] (keeping its comment) and .coveragerc into [tool.coverage.run] in pyproject.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 requires pytest>=9, and the CONTRIBUTING setup step installs it.
  • Removed pytest.ini from the CodSpeed workflow trigger paths (pyproject.toml is already there), and updated the comments in tox.ini and CONTRIBUTING.rst that referred to pytest.ini.

Test plan

  • A temporary test emitting a UserWarning and a DeprecationWarning fails on both master and this branch, and the tzlocal exemption still passes. pytest reports configfile: pyproject.toml. With pytest 8 the same probe passes, which is why the floor is needed.
  • Bare pytest collects 25,187 tests on both branches (testpaths).
  • coverage debug config shows source: dateparser, coming from pyproject.toml.
  • tox -e py312,scripts,benchmark,pre-commit,twinecheck,docs: all pass.
  • Python 3.10 with the min pins (without atheris, which does not build on macOS): pytest and coverage both read pyproject.toml via tomli, and the full suite passes.

🤖 Generated with Claude Code

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]>
@codspeed

codspeed Bot commented Oct 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 10 untouched benchmarks


Comparing hammadqureshi-web:move-pytest-coverage-config (296b20c) with master (3b43c90)

Open in CodSpeed

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.18%. Comparing base (3b43c90) to head (296b20c).

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.
📢 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.

Comment thread pyproject.toml
Comment on lines +97 to +105
# 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it is pre-existing text, but this may be a good chance for some trimming.

Suggested change
# 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.

@AdrianAtZyte
AdrianAtZyte requested a review from serhii73 October 27, 2026 11:28

@serhii73 serhii73 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 and testpaths are 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>=9 floor 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] or tomli). It works here because pytest 9 pulls in tomli there, as the PR notes, and the min environments are green.
  • Three tox.ini comments no longer name the file; pointing to [tool.pytest] in pyproject.toml would keep them actionable.

@serhii73
serhii73 merged commit bf51279 into scrapinghub:master Nov 5, 2026
20 checks passed
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.

3 participants