1
1
"""CLI tests for tmuxp load."""
2
2
3
+ from __future__ import annotations
4
+
3
5
import contextlib
4
6
import io
5
7
import pathlib
10
12
from libtmux .common import has_lt_version
11
13
from libtmux .server import Server
12
14
from libtmux .session import Session
13
- from pytest_mock import MockerFixture
14
15
15
16
from tests .constants import FIXTURE_PATH
16
17
from tests .fixtures import utils as test_utils
27
28
28
29
29
30
def test_load_workspace (
30
- server : " Server" ,
31
+ server : Server ,
31
32
monkeypatch : pytest .MonkeyPatch ,
32
33
) -> None :
33
34
"""Generic test for loading a tmuxp workspace via tmuxp load."""
@@ -49,7 +50,7 @@ def test_load_workspace(
49
50
50
51
51
52
def test_load_workspace_passes_tmux_config (
52
- server : " Server" ,
53
+ server : Server ,
53
54
monkeypatch : pytest .MonkeyPatch ,
54
55
) -> None :
55
56
"""Test tmuxp load with a tmux configuration file."""
@@ -73,7 +74,7 @@ def test_load_workspace_passes_tmux_config(
73
74
74
75
75
76
def test_load_workspace_named_session (
76
- server : " Server" ,
77
+ server : Server ,
77
78
monkeypatch : pytest .MonkeyPatch ,
78
79
) -> None :
79
80
"""Test tmuxp load with a custom tmux session name."""
@@ -101,7 +102,7 @@ def test_load_workspace_named_session(
101
102
)
102
103
def test_load_workspace_name_match_regression_252 (
103
104
tmp_path : pathlib .Path ,
104
- server : " Server" ,
105
+ server : Server ,
105
106
monkeypatch : pytest .MonkeyPatch ,
106
107
) -> None :
107
108
"""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(
141
142
142
143
143
144
def test_load_symlinked_workspace (
144
- server : " Server" ,
145
+ server : Server ,
145
146
tmp_path : pathlib .Path ,
146
147
monkeypatch : pytest .MonkeyPatch ,
147
148
) -> None :
@@ -185,6 +186,7 @@ def test_load_symlinked_workspace(
185
186
186
187
187
188
if t .TYPE_CHECKING :
189
+ from pytest_mock import MockerFixture
188
190
from typing_extensions import TypeAlias
189
191
190
192
ExpectedOutput : TypeAlias = t .Optional [t .Union [str , list [str ]]]
@@ -197,14 +199,14 @@ class CLILoadFixture(t.NamedTuple):
197
199
test_id : str
198
200
199
201
# test params
200
- cli_args : list [t . Union [ str , list [str ] ]]
202
+ cli_args : list [str | list [str ]]
201
203
config_paths : list [str ]
202
204
session_names : list [str ]
203
205
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
208
210
209
211
210
212
TEST_LOAD_FIXTURES : list [CLILoadFixture ] = [
@@ -289,7 +291,7 @@ class CLILoadFixture(t.NamedTuple):
289
291
def test_load (
290
292
tmp_path : pathlib .Path ,
291
293
tmuxp_configdir : pathlib .Path ,
292
- server : " Server" ,
294
+ server : Server ,
293
295
session : Session ,
294
296
capsys : pytest .CaptureFixture [str ],
295
297
monkeypatch : pytest .MonkeyPatch ,
@@ -298,10 +300,10 @@ def test_load(
298
300
config_paths : list [str ],
299
301
session_names : list [str ],
300
302
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 ,
305
307
) -> None :
306
308
"""Parametrized test battery for tmuxp load CLI command."""
307
309
assert server .socket_name is not None
@@ -346,7 +348,7 @@ def test_load(
346
348
347
349
def test_regression_00132_session_name_with_dots (
348
350
tmp_path : pathlib .Path ,
349
- server : " Server" ,
351
+ server : Server ,
350
352
session : Session ,
351
353
capsys : pytest .CaptureFixture [str ],
352
354
) -> None :
@@ -366,7 +368,7 @@ def test_load_zsh_autotitle_warning(
366
368
tmp_path : pathlib .Path ,
367
369
monkeypatch : pytest .MonkeyPatch ,
368
370
capsys : pytest .CaptureFixture [str ],
369
- server : " Server" ,
371
+ server : Server ,
370
372
) -> None :
371
373
"""Test loading ZSH without DISABLE_AUTO_TITLE raises warning."""
372
374
# create dummy tmuxp yaml so we don't get yelled at
@@ -548,7 +550,7 @@ def test_load_plugins_plugin_missing(
548
550
549
551
def test_plugin_system_before_script (
550
552
monkeypatch_plugin_test_packages : None ,
551
- server : " Server" ,
553
+ server : Server ,
552
554
monkeypatch : pytest .MonkeyPatch ,
553
555
) -> None :
554
556
"""Test tmuxp load with sessions using before_script."""
@@ -570,7 +572,7 @@ def test_plugin_system_before_script(
570
572
571
573
572
574
def test_load_attached (
573
- server : " Server" ,
575
+ server : Server ,
574
576
monkeypatch : pytest .MonkeyPatch ,
575
577
mocker : MockerFixture ,
576
578
) -> None :
@@ -592,7 +594,7 @@ def test_load_attached(
592
594
593
595
594
596
def test_load_attached_detached (
595
- server : " Server" ,
597
+ server : Server ,
596
598
monkeypatch : pytest .MonkeyPatch ,
597
599
mocker : MockerFixture ,
598
600
) -> None :
@@ -614,7 +616,7 @@ def test_load_attached_detached(
614
616
615
617
616
618
def test_load_attached_within_tmux (
617
- server : " Server" ,
619
+ server : Server ,
618
620
monkeypatch : pytest .MonkeyPatch ,
619
621
mocker : MockerFixture ,
620
622
) -> None :
@@ -636,7 +638,7 @@ def test_load_attached_within_tmux(
636
638
637
639
638
640
def test_load_attached_within_tmux_detached (
639
- server : " Server" ,
641
+ server : Server ,
640
642
monkeypatch : pytest .MonkeyPatch ,
641
643
mocker : MockerFixture ,
642
644
) -> None :
@@ -658,7 +660,7 @@ def test_load_attached_within_tmux_detached(
658
660
659
661
660
662
def test_load_append_windows_to_current_session (
661
- server : " Server" ,
663
+ server : Server ,
662
664
monkeypatch : pytest .MonkeyPatch ,
663
665
) -> None :
664
666
"""Test tmuxp load when windows are appended to the current session."""
0 commit comments