Skip to content

Commit 7d542d1

Browse files
committed
tests(window): Version guard to scope
1 parent a313913 commit 7d542d1

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

tests/legacy_api/test_window.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from libtmux import exc
1313
from libtmux.common import has_gte_version, has_lt_version, has_version
14+
from libtmux.constants import OptionScope
1415
from libtmux.pane import Pane
1516
from libtmux.server import Server
1617
from libtmux.window import Window
@@ -289,18 +290,37 @@ def test_set_and_show_options(session: Session) -> None:
289290
window = session.new_window(window_name="test_window")
290291

291292
window.set_option("main-pane-height", 20)
292-
assert window._show_option("main-pane-height") == 20
293+
if has_gte_version("3.0"):
294+
assert window._show_option("main-pane-height") == 20
295+
else:
296+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 20
293297

294298
window.set_option("main-pane-height", 40)
295-
assert window._show_option("main-pane-height") == 40
299+
300+
if has_gte_version("3.0"):
301+
assert window._show_option("main-pane-height") == 40
302+
else:
303+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
296304

297305
# By default, show-options will session scope, even if target is a window
298306
with pytest.raises(KeyError):
299307
assert window._show_options()["main-pane-height"] == 40
300308

309+
if has_gte_version("3.0"):
310+
assert window._show_option("main-pane-height") == 40
311+
else:
312+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
313+
301314
if has_gte_version("2.3"):
302315
window.set_option("pane-border-format", " #P ")
303-
assert window._show_option("pane-border-format") == " #P "
316+
317+
if has_gte_version("3.0"):
318+
assert window._show_option("pane-border-format") == " #P "
319+
else:
320+
assert (
321+
window._show_option("pane-border-format", scope=OptionScope.Window)
322+
== " #P "
323+
)
304324

305325

306326
def test_empty_window_option_returns_None(session: Session) -> None:

tests/test_window.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,18 +327,37 @@ def test_set_and_show_window_options(session: Session) -> None:
327327
window = session.new_window(window_name="test_window")
328328

329329
window.set_option("main-pane-height", 20)
330-
assert window._show_option("main-pane-height") == 20
330+
if has_gte_version("3.0"):
331+
assert window._show_option("main-pane-height") == 20
332+
else:
333+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 20
331334

332335
window.set_option("main-pane-height", 40)
333-
assert window._show_option("main-pane-height") == 40
336+
337+
if has_gte_version("3.0"):
338+
assert window._show_option("main-pane-height") == 40
339+
else:
340+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
334341

335342
# By default, show-options will session scope, even if target is a window
336343
with pytest.raises(KeyError):
337344
assert window._show_options()["main-pane-height"] == 40
338345

346+
if has_gte_version("3.0"):
347+
assert window._show_option("main-pane-height") == 40
348+
else:
349+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
350+
339351
if has_gte_version("2.3"):
340352
window.set_option("pane-border-format", " #P ")
341-
assert window._show_option("pane-border-format") == " #P "
353+
354+
if has_gte_version("3.0"):
355+
assert window._show_option("pane-border-format") == " #P "
356+
else:
357+
assert (
358+
window._show_option("pane-border-format", scope=OptionScope.Window)
359+
== " #P "
360+
)
342361

343362

344363
def test_empty_window_option_returns_None(session: Session) -> None:

0 commit comments

Comments
 (0)