Skip to content

Move pytest options from setup.cfg into pytest.ini so doctests run - #1983

Open
timmyloos wants to merge 2 commits into
httpie:masterfrom
timmyloos:fix/pytest-config-shadowed-by-pytest-ini
Open

timmyloos wants to merge 2 commits into
httpie:masterfrom
timmyloos:fix/pytest-config-shadowed-by-pytest-ini

Conversation

@timmyloos

@timmyloos timmyloos commented Oct 24, 2026 •

Copy link
Copy Markdown

pytest only reads the first configuration file it finds, and pytest.ini takes precedence over setup.cfg. As a result, the [tool:pytest] section in setup.cfg is silently ignored. pytest prints this on every run:

configfile: pytest.ini (WARNING: ignoring pytest config in setup.cfg!)

This means --doctest-modules, xfail_strict, testpaths and norecursedirs are not applied. In particular, make test never runs the 8 doctests in httpie/ and tests/utils/ (e.g. httpie.utils.humanize_bytes, or tests.utils.http, which #1075 previously updated).

This PR:

  1. Moves those options into pytest.ini and removes the dead section from setup.cfg.
  2. Marks TestQuietFlag::test_quiet_on_python_warnings as xfail(strict=False). Its xfail exists because the result is unreliable on Windows (per the comment above it). With xfail_strict now active, the first CI run of this PR failed on Windows + Python 3.7 with [XPASS(strict)]; the same jobs on other PRs report 1 xpassed.

Before / after (make test, Python 3.12.12, macOS):

CI: I compared the first run of this PR job-by-job with the Tests run of another open PR (run 39912759676). Apart from the Windows 3.7 XPASS fixed by the second commit, every job has the same pre-existing failures: Big5 charset detection, argparse quoting on 3.12, pyOpenSSL digest auth (Context has already been used...), plugin tests on 3.9, and Python 3.7 being unavailable on ubuntu-latest. Each job has more passing tests because of the doctests, which also pass on Windows.

pytest reads only the first config file it finds, and pytest.ini takes
precedence over setup.cfg. The [tool:pytest] section in setup.cfg was
therefore silently ignored (pytest prints "ignoring pytest config in
setup.cfg!"), so `make test` never ran the doctests enabled by
--doctest-modules and xfail_strict was not enforced.

Moving the options into pytest.ini restores the intended configuration:
8 doctests in httpie/ and tests/utils/ are now collected, and all pass.
With xfail_strict now applied from pytest.ini, this test fails on
Windows + Python 3.7 in CI with [XPASS(strict)]. Its xfail exists only
because the result is unreliable on Windows (see the comment above it),
so an occasional pass is expected. Mark it strict=False to keep the
previous behaviour for this test while enforcing strict xfail elsewhere.
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.

1 participant