11"""Conftest.py (root-level).
22
33We 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
59"""
10+
611import logging
712import os
813import pathlib
2631@pytest .mark .skipif (not USING_ZSH , reason = "Using ZSH" )
2732@pytest .fixture (autouse = USING_ZSH , scope = "session" )
2833def zshrc (user_path : pathlib .Path ) -> pathlib .Path :
29- """This quiets ZSH default message.
34+ """Quiets ZSH default message.
3035
3136 Needs a startup file .zshenv, .zprofile, .zshrc, .zlogin.
3237 """
@@ -37,11 +42,13 @@ def zshrc(user_path: pathlib.Path) -> pathlib.Path:
3742
3843@pytest .fixture (autouse = True )
3944def home_path_default (monkeypatch : pytest .MonkeyPatch , user_path : pathlib .Path ) -> None :
45+ """Set HOME to user_path (random, temporary directory)."""
4046 monkeypatch .setenv ("HOME" , str (user_path ))
4147
4248
4349@pytest .fixture
4450def tmuxp_configdir (user_path : pathlib .Path ) -> pathlib .Path :
51+ """Ensure and return tmuxp config directory."""
4552 xdg_config_dir = user_path / ".config"
4653 xdg_config_dir .mkdir (exist_ok = True )
4754
@@ -54,12 +61,14 @@ def tmuxp_configdir(user_path: pathlib.Path) -> pathlib.Path:
5461def tmuxp_configdir_default (
5562 monkeypatch : pytest .MonkeyPatch , tmuxp_configdir : pathlib .Path
5663) -> None :
64+ """Set tmuxp configuration directory for ``TMUXP_CONFIGDIR``."""
5765 monkeypatch .setenv ("TMUXP_CONFIGDIR" , str (tmuxp_configdir ))
5866 assert get_workspace_dir () == str (tmuxp_configdir )
5967
6068
6169@pytest .fixture (scope = "function" )
6270def monkeypatch_plugin_test_packages (monkeypatch : pytest .MonkeyPatch ) -> None :
71+ """Monkeypatch tmuxp plugin fixtures to python path."""
6372 paths = [
6473 "tests/fixtures/pluginsystem/plugins/tmuxp_test_plugin_bwb/" ,
6574 "tests/fixtures/pluginsystem/plugins/tmuxp_test_plugin_bs/" ,
@@ -74,12 +83,14 @@ def monkeypatch_plugin_test_packages(monkeypatch: pytest.MonkeyPatch) -> None:
7483
7584@pytest .fixture (scope = "function" )
7685def session_params (session_params : t .Dict [str , t .Any ]) -> t .Dict [str , t .Any ]:
86+ """Terminal-friendly tmuxp session_params for dimensions."""
7787 session_params .update ({"x" : 800 , "y" : 600 })
7888 return session_params
7989
8090
8191@pytest .fixture (scope = "function" )
8292def socket_name (request : pytest .FixtureRequest ) -> str :
93+ """Random socket name for tmuxp."""
8394 return "tmuxp_test%s" % next (namer )
8495
8596
@@ -89,6 +100,7 @@ def add_doctest_fixtures(
89100 doctest_namespace : t .Dict [str , t .Any ],
90101 tmp_path : pathlib .Path ,
91102) -> None :
103+ """Harness pytest fixtures to doctests namespace."""
92104 if isinstance (request ._pyfuncitem , DoctestItem ) and shutil .which ("tmux" ):
93105 doctest_namespace ["server" ] = request .getfixturevalue ("server" )
94106 session : "Session" = request .getfixturevalue ("session" )
0 commit comments