You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9b4e94d
Browse filesBrowse the repository at this point in the historyBrowse files
Keep the two kinds of shared test code in their proper places:
79
-
80
-
-**Fixtures and hooks** go in `conftest.py`. Tests receive them through
81
-
pytest's dependency injection; they never need to import `conftest` directly.
82
-
-**Plain helper functions and constants** go in `tests/helpers/`. Tests that
83
-
need them import from there explicitly, e.g.
69
+
## Shared test support
70
+
71
+
See also: https://docs.pytest.org/en/stable/reference/fixtures.html#conftest-py-sharing-fixtures-across-multiple-files
72
+
73
+
Follow these rules when adding or moving shared test code:
74
+
75
+
- Never import from a `conftest.py`.
76
+
- Put suite-wide fixtures and pytest hooks in `tests/conftest.py`. Put fixtures
77
+
needed only by one test subtree in that subtree's nearest `conftest.py`.
78
+
- Put a pytest hook in a nested `conftest.py` only if pytest supports that hook
79
+
there. If the hook receives suite-wide data, explicitly limit its effects to
80
+
the intended subtree.
81
+
- Code used only to implement fixtures or hooks may remain in the same
82
+
`conftest.py`. Put functions and constants imported by test modules in
83
+
`tests/helpers/` instead.
84
+
- Import helpers explicitly from the test root, for example:
0 commit comments