Skip to content

Commit cf9b9d5

Browse files
committed
tests(window): Version guard to scope
1 parent 656bc56 commit cf9b9d5

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
@@ -9,6 +9,7 @@
99

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

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

290294
window.set_option("main-pane-height", 40)
291-
assert window._show_option("main-pane-height") == 40
295+
296+
if has_gte_version("3.0"):
297+
assert window._show_option("main-pane-height") == 40
298+
else:
299+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
292300

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

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

301321

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

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

308311
window.set_option("main-pane-height", 40)
309-
assert window._show_option("main-pane-height") == 40
312+
313+
if has_gte_version("3.0"):
314+
assert window._show_option("main-pane-height") == 40
315+
else:
316+
assert window._show_option("main-pane-height", scope=OptionScope.Window) == 40
310317

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

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

319338

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

0 commit comments

Comments
 (0)