1
- """Conftest.py ( root-level) .
1
+ """Configure root-level pytest fixtures for libtmux .
2
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.
3
+ We keep this file at the root to make these fixtures available to all
4
+ tests, while also preventing unwanted inclusion in the distributed
5
+ wheel. Additionally, `pytest_plugins` references ensure that the
6
+ `pytester` plugin is accessible for test generation and execution.
6
7
7
- See "pytest_plugins in non-top-level conftest files" in
8
- https://docs.pytest.org/en/stable/deprecations.html
8
+ See Also
9
+ --------
10
+ pytest_plugins in non-top-level conftest files
11
+ https://docs.pytest.org/en/stable/deprecations.html
9
12
"""
10
13
11
14
from __future__ import annotations
@@ -33,7 +36,13 @@ def add_doctest_fixtures(
33
36
request : pytest .FixtureRequest ,
34
37
doctest_namespace : dict [str , t .Any ],
35
38
) -> None :
36
- """Configure doctest fixtures for pytest-doctest."""
39
+ """Configure doctest fixtures for pytest-doctest.
40
+
41
+ Automatically sets up tmux-related classes and default fixtures,
42
+ making them available in doctest namespaces if `tmux` is found
43
+ on the system. This ensures that doctest blocks referencing tmux
44
+ structures can execute smoothly in the test environment.
45
+ """
37
46
if isinstance (request ._pyfuncitem , DoctestItem ) and shutil .which ("tmux" ):
38
47
request .getfixturevalue ("set_home" )
39
48
doctest_namespace ["Server" ] = Server
@@ -53,22 +62,26 @@ def set_home(
53
62
monkeypatch : pytest .MonkeyPatch ,
54
63
user_path : pathlib .Path ,
55
64
) -> None :
56
- """Configure home directory for pytest tests ."""
65
+ """Set the HOME environment variable to the temporary user directory ."""
57
66
monkeypatch .setenv ("HOME" , str (user_path ))
58
67
59
68
60
69
@pytest .fixture (autouse = True )
61
70
def setup_fn (
62
71
clear_env : None ,
63
72
) -> None :
64
- """Function -level test configuration fixtures for pytest ."""
73
+ """Apply function -level test fixture configuration (e.g., environment cleanup) ."""
65
74
66
75
67
76
@pytest .fixture (autouse = True , scope = "session" )
68
77
def setup_session (
69
78
request : pytest .FixtureRequest ,
70
79
config_file : pathlib .Path ,
71
80
) -> None :
72
- """Session-level test configuration for pytest."""
81
+ """Apply session-level test fixture configuration for libtmux testing.
82
+
83
+ If zsh is in use, applies a suppressing `.zshrc` fix to avoid
84
+ default interactive messages that might disrupt tmux sessions.
85
+ """
73
86
if USING_ZSH :
74
87
request .getfixturevalue ("zshrc" )
0 commit comments