|
| 1 | +"""Conftest.py (root-level) |
| 2 | +
|
| 3 | +We keep this in root pytest fixtures in pytest's doctest plugin to be available, as well |
| 4 | +as avoiding conftest.py from being included in the wheel, in addition to pytest_plugin |
| 5 | +for pytester only being available via the root directory. |
| 6 | +
|
| 7 | +See "pytest_plugins in non-top-level conftest files" in |
| 8 | +https://docs.pytest.org/en/stable/deprecations.html |
| 9 | +""" |
| 10 | +import pathlib |
| 11 | +import typing as t |
| 12 | + |
| 13 | +import pytest |
| 14 | + |
| 15 | +pytest_plugins = ["pytester"] |
| 16 | + |
| 17 | + |
| 18 | +@pytest.fixture(autouse=True) |
| 19 | +def add_doctest_fixtures( |
| 20 | + request: pytest.FixtureRequest, |
| 21 | + doctest_namespace: t.Dict[str, t.Any], |
| 22 | +) -> None: |
| 23 | + from _pytest.doctest import DoctestItem |
| 24 | + |
| 25 | + if isinstance(request._pyfuncitem, DoctestItem): |
| 26 | + request.getfixturevalue("add_doctest_fixtures") |
| 27 | + request.getfixturevalue("set_home") |
| 28 | + |
| 29 | + |
| 30 | +@pytest.fixture(autouse=True) |
| 31 | +def setup( |
| 32 | + request: pytest.FixtureRequest, |
| 33 | + gitconfig: pathlib.Path, |
| 34 | + set_home: pathlib.Path, |
| 35 | +) -> None: |
| 36 | + pass |
| 37 | + |
| 38 | + |
| 39 | +@pytest.fixture(autouse=True) |
| 40 | +def cwd_default(monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path) -> None: |
| 41 | + monkeypatch.chdir(tmp_path) |
0 commit comments