Skip to content

Commit f6998eb

Browse files
committed
test(legacy_api/common): Derive next_version from TMUX_MAX_VERSION
1 parent ce89181 commit f6998eb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/legacy_api/test_common.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@
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+
3546
def test_allows_master_version(monkeypatch: pytest.MonkeyPatch) -> None:
3647
"""Assert get_version() works with builds from git trunk."""
3748

@@ -54,10 +65,10 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
5465

5566
def test_allows_next_version(monkeypatch: pytest.MonkeyPatch) -> None:
5667
"""Assert get_version() supports next version."""
57-
TMUX_NEXT_VERSION = "3.6"
68+
next_version = _get_next_tmux_version()
5869

5970
class Hi:
60-
stdout: t.ClassVar = [f"tmux next-{TMUX_NEXT_VERSION}"]
71+
stdout: t.ClassVar = [f"tmux next-{next_version}"]
6172
stderr = None
6273

6374
def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
@@ -68,7 +79,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
6879
assert has_minimum_version()
6980
assert has_gte_version(TMUX_MIN_VERSION)
7081
assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version"
71-
assert get_version() == TMUX_NEXT_VERSION
82+
assert get_version() == next_version
7283

7384

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

0 commit comments

Comments
 (0)