Skip to content

Commit 1f09111

Browse files
committed
build(conftest): Move to root level
Required by pytest_plugins to be at the top level, makes py.test README.md possible to run, as well as keeping conftest.py excluded from wheel package.
1 parent 3778bf2 commit 1f09111

File tree

5 files changed

+42
-36
lines changed

5 files changed

+42
-36
lines changed

conftest.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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)

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ packages = [
5050
]
5151
include = [
5252
{ path = "tests", format = "sdist" },
53+
{ path = "conftest.py", format = "sdist" },
5354
]
5455

5556
[tool.poetry.urls]

src/libvcs/conftest.py

-25
This file was deleted.

tests/_internal/subprocess/conftest.py

-8
This file was deleted.

tests/conftest.py

-3
This file was deleted.

0 commit comments

Comments
 (0)