Skip to content

Commit 44a2530

Browse files
committed
fix(ci): register pytest options in rootdir conftest for pytest 9.0
pytest 9.0 no longer loads pytest_addoption from tests/conftest.py when the path comes from testpaths, breaking --wiki_domain/--wiki_username/ --wiki_password ("unrecognized arguments"). Move pytest_addoption to a repo-root conftest.py (always loaded at startup) and drop the duplicate from tests/conftest.py; option-backed fixtures stay in tests/conftest.py
1 parent 316ce65 commit 44a2530

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

‎conftest.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""Root conftest for pytest.
2+
3+
``pytest_addoption`` must live in the *rootdir* conftest (or a plugin):
4+
since pytest 9.0 the hook is no longer picked up from a subdirectory
5+
conftest (e.g. ``tests/conftest.py``) reached only via ``testpaths``,
6+
which caused "unrecognized arguments: --wiki_domain ..." in CI. The
7+
option-backed fixtures stay in ``tests/conftest.py``.
8+
"""
9+
10+
11+
def pytest_addoption(parser):
12+
parser.addoption("--wiki_domain", action="store")
13+
parser.addoption("--wiki_username", action="store")
14+
parser.addoption("--wiki_password", action="store")
15+
parser.addoption("--db_username", action="store")
16+
parser.addoption("--db_password", action="store")

‎tests/conftest.py‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@
99

1010
import pytest
1111

12-
13-
def pytest_addoption(parser):
14-
parser.addoption("--wiki_domain", action="store")
15-
parser.addoption("--wiki_username", action="store")
16-
parser.addoption("--wiki_password", action="store")
17-
parser.addoption("--db_username", action="store")
18-
parser.addoption("--db_password", action="store")
12+
# Note: pytest_addoption lives in the repo-root conftest.py - since pytest 9.0
13+
# it is not loaded from this subdirectory conftest via testpaths. The
14+
# option-backed fixtures below stay here.
1915

2016

2117
@pytest.fixture(scope="session")

0 commit comments

Comments
 (0)