Skip to content

Include package doctests in the default test run - #487

Open
momooo15 wants to merge 1 commit into
python-humanize:mainfrom
momooo15:codex/enable-source-doctests
Open

momooo15 wants to merge 1 commit into
python-humanize:mainfrom
momooo15:codex/enable-source-doctests

Conversation

@momooo15

Copy link
Copy Markdown

The default test run collects 878 tests but none of the 15 package doctest items. Pytest selects the settings in pyproject.toml; the --doctest-modules option in tox.ini is not merged into that configuration. The configured testpaths also only includes tests.

Changes proposed in this pull request:

  • Enable --doctest-modules in the active pytest configuration.
  • Add humanize to testpaths and enable --pyargs so examples are collected from the same package used by the tests. This works for both editable installations and the installed distribution tested by tox, without mixing source-tree and installed modules.
  • Remove the unused [pytest] section from tox.ini so the settings have one source of truth.

Validation on macOS with Python 3.14.5 and pytest 9.1.1:

  • Before the change: python -m pytest -q — 878 passed.
  • After the change: python -m pytest -q --benchmark-disable --color=no — 893 passed, including all 15 source doctest items.
  • tox -e py -- --benchmark-disable --color=no — 893 passed against the installed distribution, with coverage enabled.
  • Temporarily replaced the expected output of the first natural_list() example with an incorrect string. The original configuration still passed all 878 tests; the updated configuration reported that doctest as the only failure (1 failed, 892 passed). The temporary edit was restored.
  • tox -e py -- tests/test_number.py -k intcomma --benchmark-disable --color=no — 36 passed, 205 deselected; focused test selection still works.
  • Translation catalogs were compiled before testing.
  • pyproject-fmt --check pyproject.toml, tox-ini-fmt --check tox.ini, and git diff --check passed.

Other platforms and Python versions have not been tested locally.

AI assistance: OpenAI Codex assisted with investigating the configuration, preparing the patch, and running the local checks.

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