Skip to content

Commit 4116228

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 786ba47 commit 4116228

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
@@ -618,3 +618,35 @@ def test_version_deprecation_warns_once(monkeypatch: pytest.MonkeyPatch) -> None
618618
libtmux.common._check_deprecated_version(LooseVersion("3.1"))
619619

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

0 commit comments

Comments
 (0)