1
- """Conftest.py (root-level)
1
+ """Conftest.py (root-level).
2
2
3
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.
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
5
9
"""
10
+
6
11
import logging
7
12
import os
8
13
import pathlib
26
31
@pytest .mark .skipif (not USING_ZSH , reason = "Using ZSH" )
27
32
@pytest .fixture (autouse = USING_ZSH , scope = "session" )
28
33
def zshrc (user_path : pathlib .Path ) -> pathlib .Path :
29
- """This quiets ZSH default message.
34
+ """Quiets ZSH default message.
30
35
31
36
Needs a startup file .zshenv, .zprofile, .zshrc, .zlogin.
32
37
"""
@@ -37,11 +42,13 @@ def zshrc(user_path: pathlib.Path) -> pathlib.Path:
37
42
38
43
@pytest .fixture (autouse = True )
39
44
def home_path_default (monkeypatch : pytest .MonkeyPatch , user_path : pathlib .Path ) -> None :
45
+ """Set HOME to user_path (random, temporary directory)."""
40
46
monkeypatch .setenv ("HOME" , str (user_path ))
41
47
42
48
43
49
@pytest .fixture
44
50
def tmuxp_configdir (user_path : pathlib .Path ) -> pathlib .Path :
51
+ """Ensure and return tmuxp config directory."""
45
52
xdg_config_dir = user_path / ".config"
46
53
xdg_config_dir .mkdir (exist_ok = True )
47
54
@@ -54,12 +61,14 @@ def tmuxp_configdir(user_path: pathlib.Path) -> pathlib.Path:
54
61
def tmuxp_configdir_default (
55
62
monkeypatch : pytest .MonkeyPatch , tmuxp_configdir : pathlib .Path
56
63
) -> None :
64
+ """Set tmuxp configuration directory for ``TMUXP_CONFIGDIR``."""
57
65
monkeypatch .setenv ("TMUXP_CONFIGDIR" , str (tmuxp_configdir ))
58
66
assert get_workspace_dir () == str (tmuxp_configdir )
59
67
60
68
61
69
@pytest .fixture (scope = "function" )
62
70
def monkeypatch_plugin_test_packages (monkeypatch : pytest .MonkeyPatch ) -> None :
71
+ """Monkeypatch tmuxp plugin fixtures to python path."""
63
72
paths = [
64
73
"tests/fixtures/pluginsystem/plugins/tmuxp_test_plugin_bwb/" ,
65
74
"tests/fixtures/pluginsystem/plugins/tmuxp_test_plugin_bs/" ,
@@ -74,12 +83,14 @@ def monkeypatch_plugin_test_packages(monkeypatch: pytest.MonkeyPatch) -> None:
74
83
75
84
@pytest .fixture (scope = "function" )
76
85
def session_params (session_params : t .Dict [str , t .Any ]) -> t .Dict [str , t .Any ]:
86
+ """Terminal-friendly tmuxp session_params for dimensions."""
77
87
session_params .update ({"x" : 800 , "y" : 600 })
78
88
return session_params
79
89
80
90
81
91
@pytest .fixture (scope = "function" )
82
92
def socket_name (request : pytest .FixtureRequest ) -> str :
93
+ """Random socket name for tmuxp."""
83
94
return "tmuxp_test%s" % next (namer )
84
95
85
96
@@ -89,6 +100,7 @@ def add_doctest_fixtures(
89
100
doctest_namespace : t .Dict [str , t .Any ],
90
101
tmp_path : pathlib .Path ,
91
102
) -> None :
103
+ """Harness pytest fixtures to doctests namespace."""
92
104
if isinstance (request ._pyfuncitem , DoctestItem ) and shutil .which ("tmux" ):
93
105
doctest_namespace ["server" ] = request .getfixturevalue ("server" )
94
106
session : "Session" = request .getfixturevalue ("session" )
0 commit comments