Skip to content

Commit 9f069a4

Browse files
committed
test(common): Add integration test for deprecation via get_version()
why: Existing tests call _check_deprecated_version() directly, missing integration issues in the full call chain. what: - Add test_version_deprecation_via_get_version() that monkeypatches tmux_cmd and calls get_version() to verify warning plumbing - Tests the complete flow: tmux_cmd → version parsing → deprecation check
1 parent 94501bb commit 9f069a4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/test_common.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,3 +607,35 @@ def test_version_deprecation_warns_once(monkeypatch: pytest.MonkeyPatch) -> None
607607
libtmux.common._check_deprecated_version(LooseVersion("3.1"))
608608

609609
assert len(w) == 1
610+
611+
612+
def test_version_deprecation_via_get_version(monkeypatch: pytest.MonkeyPatch) -> None:
613+
"""Test deprecation warning fires through get_version() call.
614+
615+
This integration test verifies the warning is emitted when calling
616+
get_version() with an old tmux version, testing the full call chain.
617+
"""
618+
import warnings
619+
620+
import libtmux.common
621+
622+
class MockTmuxOutput:
623+
stdout: t.ClassVar = ["tmux 3.1"]
624+
stderr: t.ClassVar[list[str]] = []
625+
626+
def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> MockTmuxOutput:
627+
return MockTmuxOutput()
628+
629+
monkeypatch.setattr(libtmux.common, "_version_deprecation_checked", False)
630+
monkeypatch.setattr(libtmux.common, "tmux_cmd", mock_tmux_cmd)
631+
monkeypatch.delenv("LIBTMUX_SUPPRESS_VERSION_WARNING", raising=False)
632+
633+
with warnings.catch_warnings(record=True) as w:
634+
warnings.simplefilter("always")
635+
version = libtmux.common.get_version()
636+
637+
assert str(version) == "3.1"
638+
assert len(w) == 1
639+
assert issubclass(w[0].category, FutureWarning)
640+
assert "3.1" in str(w[0].message)
641+
assert "3.2a" in str(w[0].message)

0 commit comments

Comments
 (0)