Skip to content

Commit 067329e

Browse files
committed
tests(window): Version guard to scope
1 parent 702dfe7 commit 067329e

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
@@ -307,18 +307,37 @@ def test_set_and_show_window_options(session: Session) -> None:
307307
window = session.new_window(window_name="test_window")
308308

309309
window.set_option("main-pane-height", 20)
310-
assert window._show_option("main-pane-height") == 20
310+
if has_gte_version("3.0"):
311+
assert window._show_option("main-pane-height") == 20
312+
else:
313+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 20
311314

312315
window.set_option("main-pane-height", 40)
313-
assert window._show_option("main-pane-height") == 40
316+
317+
if has_gte_version("3.0"):
318+
assert window._show_option("main-pane-height") == 40
319+
else:
320+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
314321

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

326+
if has_gte_version("3.0"):
327+
assert window._show_option("main-pane-height") == 40
328+
else:
329+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
330+
319331
if has_gte_version("2.3"):
320332
window.set_option("pane-border-format", " #P ")
321-
assert window._show_option("pane-border-format") == " #P "
333+
334+
if has_gte_version("3.0"):
335+
assert window._show_option("pane-border-format") == " #P "
336+
else:
337+
assert (
338+
window._show_option("pane-border-format", scope=OptionScope.Window)
339+
== " #P "
340+
)
322341

323342

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

0 commit comments

Comments
 (0)