Skip to content

Commit bc0077f

Browse files
committed
tests: Consolidate conftest.py to root
1 parent bd315dd commit bc0077f

File tree

4 files changed

+46
-49
lines changed

4 files changed

+46
-49
lines changed

conftest.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,47 @@
1+
import pathlib
2+
import shutil
3+
import typing as t
4+
5+
import pytest
6+
7+
from _pytest.doctest import DoctestItem
8+
9+
from libtmux.pytest_plugin import USING_ZSH
10+
11+
if t.TYPE_CHECKING:
12+
from libtmux.session import Session
13+
114
pytest_plugins = ["pytester"]
15+
16+
17+
@pytest.fixture(autouse=True)
18+
def add_doctest_fixtures(
19+
request: pytest.FixtureRequest,
20+
doctest_namespace: t.Dict[str, t.Any],
21+
) -> None:
22+
if isinstance(request._pyfuncitem, DoctestItem) and shutil.which("tmux"):
23+
request.getfixturevalue("set_home")
24+
doctest_namespace["server"] = request.getfixturevalue("server")
25+
session: "Session" = request.getfixturevalue("session")
26+
doctest_namespace["session"] = session
27+
doctest_namespace["window"] = session.attached_window
28+
doctest_namespace["pane"] = session.attached_pane
29+
doctest_namespace["request"] = request
30+
31+
32+
@pytest.fixture(autouse=True, scope="function")
33+
def set_home(
34+
monkeypatch: pytest.MonkeyPatch,
35+
user_path: pathlib.Path,
36+
) -> None:
37+
monkeypatch.setenv("HOME", str(user_path))
38+
39+
40+
@pytest.fixture(autouse=True, scope="session")
41+
@pytest.mark.usefixtures("clear_env")
42+
def setup(
43+
request: pytest.FixtureRequest,
44+
config_file: pathlib.Path,
45+
) -> None:
46+
if USING_ZSH:
47+
request.getfixturevalue("zshrc")

docs/conftest.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/libtmux/conftest.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

tests/conftest.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)