Skip to content

Commit 1abf3da

Browse files
committed
Another stab at fixing command options in tmux versions
1 parent 79fb2ef commit 1abf3da

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

tests/test_session.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88

99
from libtmux import Pane, Session, Window, exc
10-
from libtmux.common import has_gte_version
10+
from libtmux.common import has_gte_version, has_lt_version
1111
from libtmux.test import TEST_SESSION_PREFIX, namer
1212

1313
logger = logging.getLogger(__name__)
@@ -132,9 +132,12 @@ def test_empty_session_option_returns_None(session):
132132

133133
def test_show_option_unknown(session):
134134
"""Session.show_option raises UnknownOption for invalid option."""
135-
with pytest.raises(
136-
exc.InvalidOption if has_gte_version('3.0') else exc.AmbiguousOption
137-
):
135+
cmd_exception = exc.AmbiguousOption
136+
if has_gte_version('2.8') and has_lt_version('3.0'):
137+
cmd_exception = exc.UnknownOption
138+
elif has_gte_version('3.0'):
139+
cmd_exception = exc.InvalidOption
140+
with pytest.raises(cmd_exception):
138141
session.show_option('moooz')
139142

140143

tests/test_window.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88

99
from libtmux import Pane, Server, Window, exc
10-
from libtmux.common import has_gte_version
10+
from libtmux.common import has_gte_version, has_lt_version
1111

1212
logger = logging.getLogger(__name__)
1313

@@ -213,9 +213,12 @@ def test_show_window_option_unknown(session):
213213
"""Window.show_window_option raises UnknownOption for bad option key."""
214214
window = session.new_window(window_name='test_window')
215215

216-
with pytest.raises(
217-
exc.InvalidOption if has_gte_version('3.0') else exc.AmbiguousOption
218-
):
216+
cmd_exception = exc.AmbiguousOption
217+
if has_gte_version('2.8') and has_lt_version('3.0'):
218+
cmd_exception = exc.UnknownOption
219+
elif has_gte_version('3.0'):
220+
cmd_exception = exc.InvalidOption
221+
with pytest.raises(cmd_exception):
219222
window.show_window_option('moooz')
220223

221224

0 commit comments

Comments
 (0)