Skip to content

Commit 3686f3c

Browse files
committed
docs: Improve conftest.py
1 parent e45dcf2 commit 3686f3c

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

conftest.py

+23-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
"""Conftest.py (root-level).
1+
"""Configure root-level pytest fixtures for libtmux.
22
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.
67
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
912
"""
1013

1114
from __future__ import annotations
@@ -33,7 +36,13 @@ def add_doctest_fixtures(
3336
request: pytest.FixtureRequest,
3437
doctest_namespace: dict[str, t.Any],
3538
) -> 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+
"""
3746
if isinstance(request._pyfuncitem, DoctestItem) and shutil.which("tmux"):
3847
request.getfixturevalue("set_home")
3948
doctest_namespace["Server"] = Server
@@ -54,22 +63,26 @@ def set_home(
5463
monkeypatch: pytest.MonkeyPatch,
5564
user_path: pathlib.Path,
5665
) -> None:
57-
"""Configure home directory for pytest tests."""
66+
"""Set the HOME environment variable to the temporary user directory."""
5867
monkeypatch.setenv("HOME", str(user_path))
5968

6069

6170
@pytest.fixture(autouse=True)
6271
def setup_fn(
6372
clear_env: None,
6473
) -> None:
65-
"""Function-level test configuration fixtures for pytest."""
74+
"""Apply function-level test fixture configuration (e.g., environment cleanup)."""
6675

6776

6877
@pytest.fixture(autouse=True, scope="session")
6978
def setup_session(
7079
request: pytest.FixtureRequest,
7180
config_file: pathlib.Path,
7281
) -> None:
73-
"""Session-level test configuration for pytest."""
82+
"""Apply session-level test fixture configuration for libtmux testing.
83+
84+
If zsh is in use, applies a suppressing `.zshrc` fix to avoid
85+
default interactive messages that might disrupt tmux sessions.
86+
"""
7487
if USING_ZSH:
7588
request.getfixturevalue("zshrc")

0 commit comments

Comments
 (0)