Skip to content

Commit 5a81339

Browse files
committed
!squash revert tests
1 parent 77f99bf commit 5a81339

File tree

6 files changed

+62
-53
lines changed

6 files changed

+62
-53
lines changed

tests/cli/test_cli.py

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

3-
from __future__ import annotations
4-
53
import argparse
64
import contextlib
75
import pathlib
@@ -114,7 +112,7 @@ def test_pass_config_dir_argparse(
114112
def config_cmd(workspace_file: str) -> None:
115113
tmuxp_echo(find_workspace_file(workspace_file, workspace_dir=configdir))
116114

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

133131
def test_reattach_plugins(
134132
monkeypatch_plugin_test_packages: None,
135-
server: Server,
133+
server: "Server",
136134
) -> None:
137135
"""Test reattach plugin hook."""
138136
config_plugins = test_utils.read_workspace_file("workspace/builder/plugin_r.yaml")

tests/cli/test_debug_info.py

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

3-
from __future__ import annotations
3+
import pathlib
44

5-
import typing as t
5+
import pytest
66

77
from tmuxp import cli
88

9-
if t.TYPE_CHECKING:
10-
import pathlib
11-
12-
import pytest
13-
149

1510
def test_debug_info_cli(
1611
monkeypatch: pytest.MonkeyPatch,

tests/cli/test_load.py

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

3-
from __future__ import annotations
4-
53
import contextlib
64
import io
75
import pathlib
@@ -12,6 +10,7 @@
1210
from libtmux.common import has_lt_version
1311
from libtmux.server import Server
1412
from libtmux.session import Session
13+
from pytest_mock import MockerFixture
1514

1615
from tests.constants import FIXTURE_PATH
1716
from tests.fixtures import utils as test_utils
@@ -28,7 +27,7 @@
2827

2928

3029
def test_load_workspace(
31-
server: Server,
30+
server: "Server",
3231
monkeypatch: pytest.MonkeyPatch,
3332
) -> None:
3433
"""Generic test for loading a tmuxp workspace via tmuxp load."""
@@ -50,7 +49,7 @@ def test_load_workspace(
5049

5150

5251
def test_load_workspace_passes_tmux_config(
53-
server: Server,
52+
server: "Server",
5453
monkeypatch: pytest.MonkeyPatch,
5554
) -> None:
5655
"""Test tmuxp load with a tmux configuration file."""
@@ -74,7 +73,7 @@ def test_load_workspace_passes_tmux_config(
7473

7574

7675
def test_load_workspace_named_session(
77-
server: Server,
76+
server: "Server",
7877
monkeypatch: pytest.MonkeyPatch,
7978
) -> None:
8079
"""Test tmuxp load with a custom tmux session name."""
@@ -102,7 +101,7 @@ def test_load_workspace_named_session(
102101
)
103102
def test_load_workspace_name_match_regression_252(
104103
tmp_path: pathlib.Path,
105-
server: Server,
104+
server: "Server",
106105
monkeypatch: pytest.MonkeyPatch,
107106
) -> None:
108107
"""Test tmuxp load for a regression where tmux shell names would not match."""
@@ -142,7 +141,7 @@ def test_load_workspace_name_match_regression_252(
142141

143142

144143
def test_load_symlinked_workspace(
145-
server: Server,
144+
server: "Server",
146145
tmp_path: pathlib.Path,
147146
monkeypatch: pytest.MonkeyPatch,
148147
) -> None:
@@ -186,7 +185,6 @@ def test_load_symlinked_workspace(
186185

187186

188187
if t.TYPE_CHECKING:
189-
from pytest_mock import MockerFixture
190188
from typing_extensions import TypeAlias
191189

192190
ExpectedOutput: TypeAlias = t.Optional[t.Union[str, list[str]]]
@@ -199,14 +197,14 @@ class CLILoadFixture(t.NamedTuple):
199197
test_id: str
200198

201199
# test params
202-
cli_args: list[str | list[str]]
200+
cli_args: list[t.Union[str, list[str]]]
203201
config_paths: list[str]
204202
session_names: list[str]
205203
expected_exit_code: int
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
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
210208

211209

212210
TEST_LOAD_FIXTURES: list[CLILoadFixture] = [
@@ -291,7 +289,7 @@ class CLILoadFixture(t.NamedTuple):
291289
def test_load(
292290
tmp_path: pathlib.Path,
293291
tmuxp_configdir: pathlib.Path,
294-
server: Server,
292+
server: "Server",
295293
session: Session,
296294
capsys: pytest.CaptureFixture[str],
297295
monkeypatch: pytest.MonkeyPatch,
@@ -300,10 +298,10 @@ def test_load(
300298
config_paths: list[str],
301299
session_names: list[str],
302300
expected_exit_code: int,
303-
expected_in_out: ExpectedOutput,
304-
expected_not_in_out: ExpectedOutput,
305-
expected_in_err: ExpectedOutput,
306-
expected_not_in_err: ExpectedOutput,
301+
expected_in_out: "ExpectedOutput",
302+
expected_not_in_out: "ExpectedOutput",
303+
expected_in_err: "ExpectedOutput",
304+
expected_not_in_err: "ExpectedOutput",
307305
) -> None:
308306
"""Parametrized test battery for tmuxp load CLI command."""
309307
assert server.socket_name is not None
@@ -348,7 +346,7 @@ def test_load(
348346

349347
def test_regression_00132_session_name_with_dots(
350348
tmp_path: pathlib.Path,
351-
server: Server,
349+
server: "Server",
352350
session: Session,
353351
capsys: pytest.CaptureFixture[str],
354352
) -> None:
@@ -368,7 +366,7 @@ def test_load_zsh_autotitle_warning(
368366
tmp_path: pathlib.Path,
369367
monkeypatch: pytest.MonkeyPatch,
370368
capsys: pytest.CaptureFixture[str],
371-
server: Server,
369+
server: "Server",
372370
) -> None:
373371
"""Test loading ZSH without DISABLE_AUTO_TITLE raises warning."""
374372
# create dummy tmuxp yaml so we don't get yelled at
@@ -550,7 +548,7 @@ def test_load_plugins_plugin_missing(
550548

551549
def test_plugin_system_before_script(
552550
monkeypatch_plugin_test_packages: None,
553-
server: Server,
551+
server: "Server",
554552
monkeypatch: pytest.MonkeyPatch,
555553
) -> None:
556554
"""Test tmuxp load with sessions using before_script."""
@@ -572,7 +570,7 @@ def test_plugin_system_before_script(
572570

573571

574572
def test_load_attached(
575-
server: Server,
573+
server: "Server",
576574
monkeypatch: pytest.MonkeyPatch,
577575
mocker: MockerFixture,
578576
) -> None:
@@ -594,7 +592,7 @@ def test_load_attached(
594592

595593

596594
def test_load_attached_detached(
597-
server: Server,
595+
server: "Server",
598596
monkeypatch: pytest.MonkeyPatch,
599597
mocker: MockerFixture,
600598
) -> None:
@@ -616,7 +614,7 @@ def test_load_attached_detached(
616614

617615

618616
def test_load_attached_within_tmux(
619-
server: Server,
617+
server: "Server",
620618
monkeypatch: pytest.MonkeyPatch,
621619
mocker: MockerFixture,
622620
) -> None:
@@ -638,7 +636,7 @@ def test_load_attached_within_tmux(
638636

639637

640638
def test_load_attached_within_tmux_detached(
641-
server: Server,
639+
server: "Server",
642640
monkeypatch: pytest.MonkeyPatch,
643641
mocker: MockerFixture,
644642
) -> None:
@@ -660,7 +658,7 @@ def test_load_attached_within_tmux_detached(
660658

661659

662660
def test_load_append_windows_to_current_session(
663-
server: Server,
661+
server: "Server",
664662
monkeypatch: pytest.MonkeyPatch,
665663
) -> None:
666664
"""Test tmuxp load when windows are appended to the current session."""

tests/cli/test_ls.py

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

3-
from __future__ import annotations
4-
53
import contextlib
64
import pathlib
7-
import typing as t
85

9-
from tmuxp import cli
6+
import pytest
107

11-
if t.TYPE_CHECKING:
12-
import pytest
8+
from tmuxp import cli
139

1410

1511
def test_ls_cli(

tests/workspace/test_builder.py

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

3-
from __future__ import annotations
4-
53
import functools
64
import os
75
import pathlib
@@ -15,6 +13,7 @@
1513
from libtmux.common import has_gte_version, has_lt_version
1614
from libtmux.exc import LibTmuxException
1715
from libtmux.pane import Pane
16+
from libtmux.server import Server
1817
from libtmux.session import Session
1918
from libtmux.test import retry_until, temp_session
2019
from libtmux.window import Window
@@ -28,7 +27,6 @@
2827
from tmuxp.workspace.builder import WorkspaceBuilder
2928

3029
if t.TYPE_CHECKING:
31-
from libtmux.server import Server
3230

3331
class AssertCallbackProtocol(t.Protocol):
3432
"""Assertion callback type protocol."""
@@ -483,7 +481,7 @@ def test_environment_variables_warns_prior_to_tmux_3_0(
483481

484482

485483
def test_automatic_rename_option(
486-
server: Server,
484+
server: "Server",
487485
monkeypatch: pytest.MonkeyPatch,
488486
) -> None:
489487
"""Test workspace builder with automatic renaming enabled."""
@@ -1187,6 +1185,32 @@ def test_find_current_active_pane(
11871185
"""
11881186
session_name: Should execute
11891187
windows:
1188+
- panes:
1189+
- shell_command: echo "___$((1 + 3))___"
1190+
""",
1191+
),
1192+
"___4___",
1193+
True,
1194+
),
1195+
(
1196+
textwrap.dedent(
1197+
"""
1198+
session_name: Should not execute
1199+
windows:
1200+
- panes:
1201+
- shell_command:
1202+
- cmd: echo "___$((1 + 3))___"
1203+
enter: false
1204+
""",
1205+
),
1206+
"___4___",
1207+
False,
1208+
),
1209+
(
1210+
textwrap.dedent(
1211+
"""
1212+
session_name: Should execute
1213+
windows:
11901214
- panes:
11911215
- shell_command: echo "___$((1 + 3))___"
11921216
""",
@@ -1463,7 +1487,7 @@ class DefaultSizeNamespaceFixture(t.NamedTuple):
14631487
test_id: str
14641488

14651489
# test params
1466-
TMUXP_DEFAULT_SIZE: str | None
1490+
TMUXP_DEFAULT_SIZE: t.Optional[str]
14671491
raises: bool
14681492
confoverrides: dict[str, t.Any]
14691493

@@ -1497,10 +1521,10 @@ class DefaultSizeNamespaceFixture(t.NamedTuple):
14971521
)
14981522
@pytest.mark.skipif(has_lt_version("2.9"), reason="default-size only applies there")
14991523
def test_issue_800_default_size_many_windows(
1500-
server: Server,
1524+
server: "Server",
15011525
monkeypatch: pytest.MonkeyPatch,
15021526
test_id: str,
1503-
TMUXP_DEFAULT_SIZE: str | None,
1527+
TMUXP_DEFAULT_SIZE: t.Optional[str],
15041528
raises: bool,
15051529
confoverrides: dict[str, t.Any],
15061530
) -> None:

tests/workspace/test_finder.py

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

3-
from __future__ import annotations
4-
53
import argparse
64
import pathlib
75
import typing as t
@@ -269,7 +267,7 @@ def config_cmd(workspace_file: str) -> None:
269267

270268
project_config = projectdir / ".tmuxp.yaml"
271269

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

0 commit comments

Comments
 (0)