Skip to content

Commit a491dc3

Browse files
committed
!squash unrevert remaining
1 parent 5a81339 commit a491dc3

File tree

6 files changed

+53
-36
lines changed

6 files changed

+53
-36
lines changed

tests/cli/test_cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""CLI tests for tmuxp's core shell functionality."""
22

3+
from __future__ import annotations
4+
35
import argparse
46
import contextlib
57
import pathlib
@@ -112,7 +114,7 @@ def test_pass_config_dir_argparse(
112114
def config_cmd(workspace_file: str) -> None:
113115
tmuxp_echo(find_workspace_file(workspace_file, workspace_dir=configdir))
114116

115-
def check_cmd(config_arg: str) -> "_pytest.capture.CaptureResult[str]":
117+
def check_cmd(config_arg: str) -> _pytest.capture.CaptureResult[str]:
116118
args = parser.parse_args([config_arg])
117119
config_cmd(workspace_file=args.workspace_file)
118120
return capsys.readouterr()
@@ -130,7 +132,7 @@ def check_cmd(config_arg: str) -> "_pytest.capture.CaptureResult[str]":
130132

131133
def test_reattach_plugins(
132134
monkeypatch_plugin_test_packages: None,
133-
server: "Server",
135+
server: Server,
134136
) -> None:
135137
"""Test reattach plugin hook."""
136138
config_plugins = test_utils.read_workspace_file("workspace/builder/plugin_r.yaml")

tests/cli/test_debug_info.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
"""CLI tests for tmuxp debuginfo."""
22

3-
import pathlib
3+
from __future__ import annotations
44

5-
import pytest
5+
from typing import TYPE_CHECKING
66

77
from tmuxp import cli
88

9+
if TYPE_CHECKING:
10+
import pathlib
11+
12+
import pytest
13+
914

1015
def test_debug_info_cli(
1116
monkeypatch: pytest.MonkeyPatch,

tests/cli/test_load.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""CLI tests for tmuxp load."""
22

3+
from __future__ import annotations
4+
35
import contextlib
46
import io
57
import pathlib
@@ -10,7 +12,6 @@
1012
from libtmux.common import has_lt_version
1113
from libtmux.server import Server
1214
from libtmux.session import Session
13-
from pytest_mock import MockerFixture
1415

1516
from tests.constants import FIXTURE_PATH
1617
from tests.fixtures import utils as test_utils
@@ -27,7 +28,7 @@
2728

2829

2930
def 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

5152
def 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

7576
def 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
)
102103
def 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

143144
def 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

187188
if 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

210212
TEST_LOAD_FIXTURES: list[CLILoadFixture] = [
@@ -289,7 +291,7 @@ class CLILoadFixture(t.NamedTuple):
289291
def 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

347349
def 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

549551
def 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

572574
def 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

594596
def 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

616618
def 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

638640
def 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

660662
def 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."""

tests/cli/test_ls.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
"""CLI tests for tmuxp ls command."""
22

3+
from __future__ import annotations
4+
35
import contextlib
46
import pathlib
5-
6-
import pytest
7+
from typing import TYPE_CHECKING
78

89
from tmuxp import cli
910

11+
if TYPE_CHECKING:
12+
import pytest
13+
1014

1115
def test_ls_cli(
1216
monkeypatch: pytest.MonkeyPatch,

tests/workspace/test_builder.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Test for tmuxp workspace builder."""
22

3+
from __future__ import annotations
4+
35
import functools
46
import os
57
import pathlib
@@ -13,7 +15,6 @@
1315
from libtmux.common import has_gte_version, has_lt_version
1416
from libtmux.exc import LibTmuxException
1517
from libtmux.pane import Pane
16-
from libtmux.server import Server
1718
from libtmux.session import Session
1819
from libtmux.test import retry_until, temp_session
1920
from libtmux.window import Window
@@ -27,6 +28,7 @@
2728
from tmuxp.workspace.builder import WorkspaceBuilder
2829

2930
if t.TYPE_CHECKING:
31+
from libtmux.server import Server
3032

3133
class AssertCallbackProtocol(t.Protocol):
3234
"""Assertion callback type protocol."""
@@ -481,7 +483,7 @@ def test_environment_variables_warns_prior_to_tmux_3_0(
481483

482484

483485
def test_automatic_rename_option(
484-
server: "Server",
486+
server: Server,
485487
monkeypatch: pytest.MonkeyPatch,
486488
) -> None:
487489
"""Test workspace builder with automatic renaming enabled."""
@@ -1487,7 +1489,7 @@ class DefaultSizeNamespaceFixture(t.NamedTuple):
14871489
test_id: str
14881490

14891491
# test params
1490-
TMUXP_DEFAULT_SIZE: t.Optional[str]
1492+
TMUXP_DEFAULT_SIZE: str | None
14911493
raises: bool
14921494
confoverrides: dict[str, t.Any]
14931495

@@ -1521,10 +1523,10 @@ class DefaultSizeNamespaceFixture(t.NamedTuple):
15211523
)
15221524
@pytest.mark.skipif(has_lt_version("2.9"), reason="default-size only applies there")
15231525
def test_issue_800_default_size_many_windows(
1524-
server: "Server",
1526+
server: Server,
15251527
monkeypatch: pytest.MonkeyPatch,
15261528
test_id: str,
1527-
TMUXP_DEFAULT_SIZE: t.Optional[str],
1529+
TMUXP_DEFAULT_SIZE: str | None,
15281530
raises: bool,
15291531
confoverrides: dict[str, t.Any],
15301532
) -> None:

tests/workspace/test_finder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Test config file searching for tmuxp."""
22

3+
from __future__ import annotations
4+
35
import argparse
46
import pathlib
57
import typing as t
@@ -267,7 +269,7 @@ def config_cmd(workspace_file: str) -> None:
267269

268270
project_config = projectdir / ".tmuxp.yaml"
269271

270-
def check_cmd(config_arg: str) -> "_pytest.capture.CaptureResult[str]":
272+
def check_cmd(config_arg: str) -> _pytest.capture.CaptureResult[str]:
271273
args = parser.parse_args([config_arg])
272274
config_cmd(workspace_file=args.workspace_file)
273275
return capsys.readouterr()

0 commit comments

Comments
 (0)