Skip to content

Commit 09d9cc5

Browse files
committed
tests(window): Version guard to scope
1 parent ca196a8 commit 09d9cc5

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

331331
window.set_option("main-pane-height", 20)
332-
assert window._show_option("main-pane-height") == 20
332+
if has_gte_version("3.0"):
333+
assert window._show_option("main-pane-height") == 20
334+
else:
335+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 20
333336

334337
window.set_option("main-pane-height", 40)
335-
assert window._show_option("main-pane-height") == 40
338+
339+
if has_gte_version("3.0"):
340+
assert window._show_option("main-pane-height") == 40
341+
else:
342+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
336343

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

348+
if has_gte_version("3.0"):
349+
assert window._show_option("main-pane-height") == 40
350+
else:
351+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
352+
341353
if has_gte_version("2.3"):
342354
window.set_option("pane-border-format", " #P ")
343-
assert window._show_option("pane-border-format") == " #P "
355+
356+
if has_gte_version("3.0"):
357+
assert window._show_option("pane-border-format") == " #P "
358+
else:
359+
assert (
360+
window._show_option("pane-border-format", scope=OptionScope.Window)
361+
== " #P "
362+
)
344363

345364

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

0 commit comments

Comments
 (0)