11"""CLI tests for tmuxp load."""
22
3+ from __future__ import annotations
4+
35import contextlib
46import io
57import pathlib
1012from libtmux .common import has_lt_version
1113from libtmux .server import Server
1214from libtmux .session import Session
13- from pytest_mock import MockerFixture
1415
1516from tests .constants import FIXTURE_PATH
1617from tests .fixtures import utils as test_utils
2728
2829
2930def test_load_workspace (
30- server : " Server" ,
31+ server : Server ,
3132 monkeypatch : pytest .MonkeyPatch ,
3233) -> None :
3334 """Generic test for loading a tmuxp workspace via tmuxp load."""
@@ -49,7 +50,7 @@ def test_load_workspace(
4950
5051
5152def test_load_workspace_passes_tmux_config (
52- server : " Server" ,
53+ server : Server ,
5354 monkeypatch : pytest .MonkeyPatch ,
5455) -> None :
5556 """Test tmuxp load with a tmux configuration file."""
@@ -73,7 +74,7 @@ def test_load_workspace_passes_tmux_config(
7374
7475
7576def test_load_workspace_named_session (
76- server : " Server" ,
77+ server : Server ,
7778 monkeypatch : pytest .MonkeyPatch ,
7879) -> None :
7980 """Test tmuxp load with a custom tmux session name."""
@@ -101,7 +102,7 @@ def test_load_workspace_named_session(
101102)
102103def test_load_workspace_name_match_regression_252 (
103104 tmp_path : pathlib .Path ,
104- server : " Server" ,
105+ server : Server ,
105106 monkeypatch : pytest .MonkeyPatch ,
106107) -> None :
107108 """Test tmuxp load for a regression where tmux shell names would not match."""
@@ -141,7 +142,7 @@ def test_load_workspace_name_match_regression_252(
141142
142143
143144def test_load_symlinked_workspace (
144- server : " Server" ,
145+ server : Server ,
145146 tmp_path : pathlib .Path ,
146147 monkeypatch : pytest .MonkeyPatch ,
147148) -> None :
@@ -185,6 +186,7 @@ def test_load_symlinked_workspace(
185186
186187
187188if t .TYPE_CHECKING :
189+ from pytest_mock import MockerFixture
188190 from typing_extensions import TypeAlias
189191
190192 ExpectedOutput : TypeAlias = t .Optional [t .Union [str , list [str ]]]
@@ -197,14 +199,14 @@ class CLILoadFixture(t.NamedTuple):
197199 test_id : str
198200
199201 # test params
200- cli_args : list [t . Union [ str , list [str ] ]]
202+ cli_args : list [str | list [str ]]
201203 config_paths : list [str ]
202204 session_names : list [str ]
203205 expected_exit_code : int
204- expected_in_out : " ExpectedOutput" = None
205- expected_not_in_out : " ExpectedOutput" = None
206- expected_in_err : " ExpectedOutput" = None
207- expected_not_in_err : " ExpectedOutput" = None
206+ expected_in_out : ExpectedOutput = None
207+ expected_not_in_out : ExpectedOutput = None
208+ expected_in_err : ExpectedOutput = None
209+ expected_not_in_err : ExpectedOutput = None
208210
209211
210212TEST_LOAD_FIXTURES : list [CLILoadFixture ] = [
@@ -289,7 +291,7 @@ class CLILoadFixture(t.NamedTuple):
289291def test_load (
290292 tmp_path : pathlib .Path ,
291293 tmuxp_configdir : pathlib .Path ,
292- server : " Server" ,
294+ server : Server ,
293295 session : Session ,
294296 capsys : pytest .CaptureFixture [str ],
295297 monkeypatch : pytest .MonkeyPatch ,
@@ -298,10 +300,10 @@ def test_load(
298300 config_paths : list [str ],
299301 session_names : list [str ],
300302 expected_exit_code : int ,
301- expected_in_out : " ExpectedOutput" ,
302- expected_not_in_out : " ExpectedOutput" ,
303- expected_in_err : " ExpectedOutput" ,
304- expected_not_in_err : " ExpectedOutput" ,
303+ expected_in_out : ExpectedOutput ,
304+ expected_not_in_out : ExpectedOutput ,
305+ expected_in_err : ExpectedOutput ,
306+ expected_not_in_err : ExpectedOutput ,
305307) -> None :
306308 """Parametrized test battery for tmuxp load CLI command."""
307309 assert server .socket_name is not None
@@ -346,7 +348,7 @@ def test_load(
346348
347349def test_regression_00132_session_name_with_dots (
348350 tmp_path : pathlib .Path ,
349- server : " Server" ,
351+ server : Server ,
350352 session : Session ,
351353 capsys : pytest .CaptureFixture [str ],
352354) -> None :
@@ -366,7 +368,7 @@ def test_load_zsh_autotitle_warning(
366368 tmp_path : pathlib .Path ,
367369 monkeypatch : pytest .MonkeyPatch ,
368370 capsys : pytest .CaptureFixture [str ],
369- server : " Server" ,
371+ server : Server ,
370372) -> None :
371373 """Test loading ZSH without DISABLE_AUTO_TITLE raises warning."""
372374 # create dummy tmuxp yaml so we don't get yelled at
@@ -548,7 +550,7 @@ def test_load_plugins_plugin_missing(
548550
549551def test_plugin_system_before_script (
550552 monkeypatch_plugin_test_packages : None ,
551- server : " Server" ,
553+ server : Server ,
552554 monkeypatch : pytest .MonkeyPatch ,
553555) -> None :
554556 """Test tmuxp load with sessions using before_script."""
@@ -570,7 +572,7 @@ def test_plugin_system_before_script(
570572
571573
572574def test_load_attached (
573- server : " Server" ,
575+ server : Server ,
574576 monkeypatch : pytest .MonkeyPatch ,
575577 mocker : MockerFixture ,
576578) -> None :
@@ -592,7 +594,7 @@ def test_load_attached(
592594
593595
594596def test_load_attached_detached (
595- server : " Server" ,
597+ server : Server ,
596598 monkeypatch : pytest .MonkeyPatch ,
597599 mocker : MockerFixture ,
598600) -> None :
@@ -614,7 +616,7 @@ def test_load_attached_detached(
614616
615617
616618def test_load_attached_within_tmux (
617- server : " Server" ,
619+ server : Server ,
618620 monkeypatch : pytest .MonkeyPatch ,
619621 mocker : MockerFixture ,
620622) -> None :
@@ -636,7 +638,7 @@ def test_load_attached_within_tmux(
636638
637639
638640def test_load_attached_within_tmux_detached (
639- server : " Server" ,
641+ server : Server ,
640642 monkeypatch : pytest .MonkeyPatch ,
641643 mocker : MockerFixture ,
642644) -> None :
@@ -658,7 +660,7 @@ def test_load_attached_within_tmux_detached(
658660
659661
660662def test_load_append_windows_to_current_session (
661- server : " Server" ,
663+ server : Server ,
662664 monkeypatch : pytest .MonkeyPatch ,
663665) -> None :
664666 """Test tmuxp load when windows are appended to the current session."""
0 commit comments