Repository navigation
Expand file tree
/
Copy pathconftest.py
More file actions
49 lines (41 loc) · 2.27 KB
/
Copy pathconftest.py
File metadata and controls
49 lines (41 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""Purpose: set up the suite's import path and load its four harness plugins.
`_workspace.on_path()` is the one implementation of the path; this is the hook
that runs it before a test module imports a member. The benchmark drivers call
the same function for the same reason, since they run as their own processes.
`tests._xdist_scheduling` keeps a replaced xdist worker from wedging the run,
`tests._progress_timeout` times each item by its progress, not the clock,
`tests._full_width` decides the run's width once it knows its tests, and
`tests._worker_history` keeps each process's order of items beside the run's
log and replays one.
Assumes: this file's directory is importable, which pytest's `pythonpath = ["."]`
provides and which this file also arranges for itself, because a conftest is
imported before that setting is applied in some invocations.
Guarantees:
- `import metta_<name>` works anywhere in this suite [tested:
ext/metta-pandas/tests/test_pandas.py; commit=94057a0f073c0fab0a35c42beff2c324d8a0addd]
- every run under this rootdir loads `tests._xdist_scheduling` and
`tests._progress_timeout` [tested: test_the_suite_loads_the_restart_scheduler,
test_the_suite_times_items_by_progress; commit=51660d49c0291583453328617e311fad6ff028f0]
- every run under this rootdir loads `tests._full_width`
[tested 2026-09-27T02:16:58+10:00: test_the_suite_decides_its_width]
- every run under this rootdir loads `tests._worker_history`
[tested 2026-09-29T16:37:35+10:00: test_the_suite_records_worker_histories]
Open Obligations:
To Do: None
Hacks: None
Future Enhancements: None
"""
from __future__ import annotations
import sys
from pathlib import Path
_HERE = str(Path(__file__).resolve().parent)
if _HERE not in sys.path:
sys.path.insert(0, _HERE)
from _workspace import on_path # noqa: E402 -- the path is arranged just above
on_path()
# Here and nowhere lower: pytest honours `pytest_plugins` only in the top-level
# conftest, and this one is loaded by every run beneath it, a run narrowed to
# one file included
# [source: https://docs.pytest.org/en/stable/deprecations.html#pytest-plugins-in-non-top-level-conftest-files].
pytest_plugins = ["tests._xdist_scheduling", "tests._progress_timeout", "tests._full_width",
"tests._worker_history"]