-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
I'm using pytest 8.4.1, Python 3.11. I'm on a Mac, but I also see this problem in our Linux-based CI.
My test suite contains several conftest.py
files in the file tree. In one context, I want to run a test suite without using a top-level conftest.py
, so when I run the test suite, I do so with -p no:/Users/xxx/src/watthouse/watthouse/conftest.py
.
With versions of pytest up to and including 7.4.4, this works fine. With versions ≥ 8.0.0, I get this --
AssertionError: While trying to load conftest path /Users/xxx/src/watthouse/watthouse/conftest.py, found that the module <module 'watthouse.conftest' from '/Users/xxx/src/watthouse/watthouse/conftest.py'> is already loaded with path /Users/xxx/src/watthouse/watthouse/conftest.py. This is not supposed to happen. Please report this issue to pytest.
In the debugger, I can see in consider_pluginarg()
in _pytest/config/__init__.py
that my -p no:
option is interpreted correctly, and self.set_blocked(name)
is executed. I'm not sure where to debug from there. If I can help, LMK.
This project is many years old and has accumulated a lot of pieces and parts over time, so it's far from a scenario that I can share with you so you can reproduce the problem on your end. 😕 I created a simple project with a file layout that has conftest.py in the same places, but was not able to reproduce the problem with that simple project.
pip list
output
$ pip list
Package Version
------------------------ ------------
alembic 1.11.2
ameff_util 1.0.66
amqp 5.3.1
beautifulsoup4 4.12.2
billiard 4.2.1
black 24.4.2
blinker 1.9.0
boto3 1.34.65
botocore 1.34.162
build 1.2.2.post1
cachetools 5.5.2
celery 5.3.4
certifi 2025.7.14
cffi 1.17.1
charset-normalizer 3.4.2
click 8.2.1
click-didyoumean 0.3.1
click-plugins 1.1.1.2
click-repl 0.3.0
cryptography 44.0.2
et_xmlfile 2.0.0
factory-boy 3.3.0
Faker 37.4.2
fastcore 1.8.5
Flask 2.3.3
Flask-Admin 1.6.1
Flask-Login 0.6.3
Flask-WTF 1.2.1
GeoAlchemy2 0.14.2
ghapi 1.0.4
gitdb 4.0.12
GitPython 3.1.44
google-api-core 2.25.1
google-api-python-client 2.106.0
google-auth 2.40.3
google-auth-httplib2 0.2.0
googleapis-common-protos 1.70.0
greenlet 3.0.1
gunicorn 23.0.0
httplib2 0.22.0
idna 3.10
iniconfig 2.1.0
itsdangerous 2.2.0
Jinja2 3.1.6
jmespath 1.0.1
kombu 5.5.4
Mako 1.3.10
MarkupSafe 3.0.2
mypy_extensions 1.1.0
openpyxl 3.1.2
packaging 25.0
pathspec 0.12.1
pdfminer.six 20231228
pdfplumber 0.11.0
pillow 11.3.0
pip 25.2
pip-tools 7.4.1
platformdirs 4.3.8
pluggy 1.6.0
prompt_toolkit 3.0.51
proto-plus 1.26.1
protobuf 6.31.1
psycopg2 2.9.9
pyasn1 0.6.1
pyasn1_modules 0.4.2
pycparser 2.22
Pygments 2.19.2
PyJWT 2.8.0
pyparsing 3.2.3
pypdfium2 4.30.1
pyproject_hooks 1.2.0
pytest 8.4.1
pytest-ruff 0.4.1
python-dateutil 2.9.0.post0
pytz 2023.3.post1
pyxlsb 1.0.10
PyYAML 6.0.1
redis 5.0.1
requests 2.32.4
rsa 4.9.1
ruff 0.12.3
s3transfer 0.10.4
setuptools 80.9.0
six 1.17.0
slack-sdk 3.23.0
smmap 5.0.2
soupsieve 2.7
SQLAlchemy 2.0.23
tenacity 8.2.3
typing_extensions 4.14.1
tzdata 2025.2
uritemplate 4.2.0
urllib3 2.5.0
vine 5.1.0
wcwidth 0.2.13
Werkzeug 3.0.6
wheel 0.45.1
WTForms 3.1.2