Repository navigation
doc: fix pytest_load_initial_conftests example referring to conftest.py - #14686
PranavAchar01 wants to merge 1 commit into
Conversation
The 'Dynamically adding command line options' example defines pytest_load_initial_conftests under a '# installable external plugin' comment but the following prose called it 'the above conftest.py'. This contradicts the hook reference, which states the hook is not called for conftest files. Refer to it as a plugin instead. Closes pytest-dev#4482
LaTranquillum
left a comment
There was a problem hiding this comment.
Adjacent, pre-existing issue in the example this PR clarifies (not a regression introduced by this change): max(multiprocessing.cpu_count() / 2, 1) can produce a float, which pytest-xdist rejects as the value of -n.
A local reproduction with CPython 3.14.2, pytest 9.1.1 and pytest-xdist 3.8.0 loaded the example as example_plugin.py using:
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -B -m pytest -p xdist.plugin -p example_plugin -qThe reproduction fixed multiprocessing.cpu_count() at 2 to bound worker creation and used one trivial passing test. The original expression produced 1.0, and pytest exited with code 4 before collection:
argument -n/--numprocesses: invalid parse_numprocesses value: '1.0'
Changing the calculation to integer division:
num = max(multiprocessing.cpu_count() // 2, 1)produced one worker and 1 passed (exit 0). Could this small correction be included, or handled separately if you prefer to keep this PR strictly to the plugin wording?
Validation: two local invocations on macOS; no full suite or documentation build.
Disclosure: Codex assisted with the investigation, ran the reproduction, and drafted this feedback; I reviewed the finding and authorized submission.
Closes #4482.
The "Dynamically adding command line options" example in
doc/en/example/simple.rstdefinespytest_load_initial_conftestsunder a# installable external plugincomment, but the following prose referred to it as "the above conftest.py". That contradicts the hook reference in_pytest/hookspec.py, which states:@RonnyPfannschmidt confirmed in the issue that this is "indeed a mistake". This changes the wording to "the above plugin" so the example is consistent with the hook's documented behavior (it only runs from an installable plugin, not a project
conftest.py).Docs-only change; added a
changelog/4482.doc.rstentry.This documentation fix was prepared with the assistance of Claude Code and verified against the hook reference and the issue.