Our tests currently rely on __init__.py files so that shared fixtures can be imported explicitly, e.g. from test.fixtures.<module> import .... This makes test/ an importable package.
scientific-python recommends against putting __init__.py in the tests directory (as it can confuse package-discovery), and share fixtures through conftest.py instead, which pytest auto-discovers so no import is needed (yay!). See https://learn.scientific-python.org/development/guides/pytest/
Note: conftest.py only auto-shares @pytest.fixture-decorated objects. Plain helper functions, stub model classes, and constants currently living in the fixture modules are not auto-imported.
Proposed change
- Remove
__init__.py from the test directories.
- Move shared fixtures into
conftest.py files, scoped by location:
- Fixtures used across all tests → top-level
test/conftest.py.
- Fixtures specific to a subtree → a local
conftest.py, e.g. test/test_longitudinal/conftest.py.
- Replace explicit fixture imports (
from test.fixtures... import ...) with fixtures injected by argument name.
Our tests currently rely on
__init__.pyfiles so that shared fixtures can be imported explicitly, e.g.from test.fixtures.<module> import .... This makestest/an importable package.scientific-python recommends against putting
__init__.pyin the tests directory (as it can confuse package-discovery), and share fixtures throughconftest.pyinstead, which pytest auto-discovers so no import is needed (yay!). See https://learn.scientific-python.org/development/guides/pytest/Note:
conftest.pyonly auto-shares@pytest.fixture-decorated objects. Plain helper functions, stub model classes, and constants currently living in the fixture modules are not auto-imported.Proposed change
__init__.pyfrom the test directories.conftest.pyfiles, scoped by location:test/conftest.py.conftest.py, e.g.test/test_longitudinal/conftest.py.from test.fixtures... import ...) with fixtures injected by argument name.