Skip to content

Commit 0afdf12

Browse files
committed
tests(window): Version guard to scope
1 parent 0066c8c commit 0afdf12

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
@@ -8,6 +8,7 @@
88

99
from libtmux import exc
1010
from libtmux.common import has_gte_version, has_lt_version, has_version
11+
from libtmux.constants import OptionScope
1112
from libtmux.pane import Pane
1213
from libtmux.server import Server
1314
from libtmux.session import Session
@@ -284,18 +285,37 @@ def test_set_and_show_options(session: Session) -> None:
284285
window = session.new_window(window_name="test_window")
285286

286287
window.set_option("main-pane-height", 20)
287-
assert window._show_option("main-pane-height") == 20
288+
if has_gte_version("3.0"):
289+
assert window._show_option("main-pane-height") == 20
290+
else:
291+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 20
288292

289293
window.set_option("main-pane-height", 40)
290-
assert window._show_option("main-pane-height") == 40
294+
295+
if has_gte_version("3.0"):
296+
assert window._show_option("main-pane-height") == 40
297+
else:
298+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
291299

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

304+
if has_gte_version("3.0"):
305+
assert window._show_option("main-pane-height") == 40
306+
else:
307+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
308+
296309
if has_gte_version("2.3"):
297310
window.set_option("pane-border-format", " #P ")
298-
assert window._show_option("pane-border-format") == " #P "
311+
312+
if has_gte_version("3.0"):
313+
assert window._show_option("pane-border-format") == " #P "
314+
else:
315+
assert (
316+
window._show_option("pane-border-format", scope=OptionScope.Window)
317+
== " #P "
318+
)
299319

300320

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

304304
window.set_option("main-pane-height", 20)
305-
assert window._show_option("main-pane-height") == 20
305+
if has_gte_version("3.0"):
306+
assert window._show_option("main-pane-height") == 20
307+
else:
308+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 20
306309

307310
window.set_option("main-pane-height", 40)
308-
assert window._show_option("main-pane-height") == 40
311+
312+
if has_gte_version("3.0"):
313+
assert window._show_option("main-pane-height") == 40
314+
else:
315+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
309316

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

321+
if has_gte_version("3.0"):
322+
assert window._show_option("main-pane-height") == 40
323+
else:
324+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
325+
314326
if has_gte_version("2.3"):
315327
window.set_option("pane-border-format", " #P ")
316-
assert window._show_option("pane-border-format") == " #P "
328+
329+
if has_gte_version("3.0"):
330+
assert window._show_option("pane-border-format") == " #P "
331+
else:
332+
assert (
333+
window._show_option("pane-border-format", scope=OptionScope.Window)
334+
== " #P "
335+
)
317336

318337

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

0 commit comments

Comments
 (0)