Given the following source tree
src
└── tst
├── __init__.py
├── py.typed
└── tests
├── conftest.py
└── test_foo.py
and
# src/tst/tests/conftest.py
def pytest_configure(config):
print("custom pytest_configure called !")
def pytest_report_header(config, start_path):
1/0
(the rest of the contents doesn't matter)
I would expect both my custom pytest_configure and pytest_report_header impls to be called, but only the former is
❯ pytest
========================== test session starts ==========================
platform darwin -- Python 3.14.4, pytest-9.0.3, pluggy-1.6.0
rootdir: /private/tmp/tst
configfile: pyproject.toml
collecting ... custom pytest_configure called !
collected 1 item
src/tst/tests/test_foo.py . [100%]
=========================== 1 passed in 0.00s ===========================
I can reproduce this without anything on my env but pytest and its own dependencies:
Package Version
--------- -------
iniconfig 2.3.0
packaging 26.2
pluggy 1.6.0
pygments 2.20.0
pytest 9.0.3
reproduced on Macos Tahoe and ubuntu 24.04
The documentation says the following about pytest_configure
This hook is only called for initial conftests.
And the linked paragraph says this about "initial conftests"
for each test path, load conftest.py and test*/conftest.py relative to the directory part of the test path
which reads to me like it should include src/tst/tests/conftest.py, but it seems that it doesn't ?
Seems to me at least one of the following is true:
- there is a bug in how initial conftests are processed
- the documentation is incorrect
- I don't understand what a "test path" means (FTR, I assume this refers to the path of any test module)
pip listfrom the virtual environment you are usingGiven the following source tree
and
(the rest of the contents doesn't matter)
I would expect both my custom
pytest_configureandpytest_report_headerimpls to be called, but only the former isI can reproduce this without anything on my env but pytest and its own dependencies:
reproduced on Macos Tahoe and ubuntu 24.04
The documentation says the following about
pytest_configureAnd the linked paragraph says this about "initial conftests"
which reads to me like it should include
src/tst/tests/conftest.py, but it seems that it doesn't ?Seems to me at least one of the following is true: