Skip to content

Commit 525a1b0

Browse files
committed
test(common): Simplify next_version tests - use fixed version string
why: The _get_next_tmux_version() helper duplicates version parsing logic already in common.py and is unnecessary for testing prefix stripping. what: - Remove _get_next_tmux_version() helper from both test files - Use fixed "3.9" version string instead of calculated version - Remove unrelated has_gt_version(TMUX_MAX_VERSION) assertion - Test focuses on parsing "next-X.Y" strings, not version comparison
1 parent 4116228 commit 525a1b0

File tree

2 files changed

+5
-30
lines changed

2 files changed

+5
-30
lines changed

tests/legacy_api/test_common.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@
3232
version_regex = re.compile(r"([0-9]\.[0-9])|(master)")
3333

3434

35-
def _get_next_tmux_version() -> str:
36-
"""Derive next tmux version from TMUX_MAX_VERSION.
37-
38-
Strips trailing letters and increments minor version.
39-
E.g., "3.5a" -> "3.6"
40-
"""
41-
base = re.sub(r"[a-z]+$", "", TMUX_MAX_VERSION)
42-
major, minor = base.split(".")
43-
return f"{major}.{int(minor) + 1}"
44-
45-
4635
def test_allows_master_version(monkeypatch: pytest.MonkeyPatch) -> None:
4736
"""Assert get_version() works with builds from git trunk."""
4837

@@ -64,11 +53,10 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
6453

6554

6655
def test_allows_next_version(monkeypatch: pytest.MonkeyPatch) -> None:
67-
"""Assert get_version() supports next version."""
68-
next_version = _get_next_tmux_version()
56+
"""Assert get_version() supports next-prefixed versions."""
6957

7058
class Hi:
71-
stdout: t.ClassVar = [f"tmux next-{next_version}"]
59+
stdout: t.ClassVar = ["tmux next-3.9"]
7260
stderr = None
7361

7462
def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
@@ -78,8 +66,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
7866

7967
assert has_minimum_version()
8068
assert has_gte_version(TMUX_MIN_VERSION)
81-
assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version"
82-
assert get_version() == next_version
69+
assert get_version() == "3.9"
8370

8471

8572
def test_get_version_openbsd(monkeypatch: pytest.MonkeyPatch) -> None:

tests/test_common.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@
3232
version_regex = re.compile(r"([0-9]\.[0-9])|(master)")
3333

3434

35-
def _get_next_tmux_version() -> str:
36-
"""Derive next tmux version from TMUX_MAX_VERSION.
37-
38-
Strips trailing letters and increments minor version.
39-
E.g., "3.5a" -> "3.6"
40-
"""
41-
base = re.sub(r"[a-z]+$", "", TMUX_MAX_VERSION)
42-
major, minor = base.split(".")
43-
return f"{major}.{int(minor) + 1}"
44-
45-
4635
def test_has_version() -> None:
4736
"""Test has_version()."""
4837
assert has_version(str(get_version()))
@@ -309,10 +298,10 @@ class VersionParsingFixture(t.NamedTuple):
309298
),
310299
VersionParsingFixture(
311300
test_id="next_version",
312-
mock_stdout=[f"tmux next-{_get_next_tmux_version()}"],
301+
mock_stdout=["tmux next-3.9"],
313302
mock_stderr=None,
314303
mock_platform=None,
315-
expected_version=_get_next_tmux_version(),
304+
expected_version="3.9",
316305
raises=False,
317306
exc_msg_regex=None,
318307
),
@@ -374,7 +363,6 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> MockTmuxOutput:
374363
assert get_version() == expected_version
375364
assert has_minimum_version()
376365
assert has_gte_version(TMUX_MIN_VERSION)
377-
assert has_gt_version(TMUX_MAX_VERSION)
378366

379367

380368
class VersionValidationFixture(t.NamedTuple):

0 commit comments

Comments
 (0)