Skip to content

Commit 226fa0c

Browse files
committed
tests(window): version guard to scope
1 parent 35d3222 commit 226fa0c

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

tests/legacy_api/test_window.py

+23-3
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
11+
from libtmux.constants import OptionScope
1112
from libtmux.pane import Pane
1213
from libtmux.server import Server
1314
from libtmux.session import Session
@@ -232,18 +233,37 @@ def test_set_and_show_options(session: Session) -> None:
232233
window = session.new_window(window_name="test_window")
233234

234235
window.set_option("main-pane-height", 20)
235-
assert window.show_option("main-pane-height") == 20
236+
if has_gte_version("3.0"):
237+
assert window.show_option("main-pane-height") == 20
238+
else:
239+
assert window.show_option("main-pane-height", scope=OptionScope.Window) == 20
236240

237241
window.set_option("main-pane-height", 40)
238-
assert window.show_option("main-pane-height") == 40
242+
243+
if has_gte_version("3.0"):
244+
assert window.show_option("main-pane-height") == 40
245+
else:
246+
assert window.show_option("main-pane-height", scope=OptionScope.Window) == 40
239247

240248
# By default, show-options will session scope, even if target is a window
241249
with pytest.raises(KeyError):
242250
assert window.show_options()["main-pane-height"] == 40
243251

252+
if has_gte_version("3.0"):
253+
assert window.show_option("main-pane-height") == 40
254+
else:
255+
assert window.show_option("main-pane-height", scope=OptionScope.Window) == 40
256+
244257
if has_gte_version("2.3"):
245258
window.set_option("pane-border-format", " #P ")
246-
assert window.show_option("pane-border-format") == " #P "
259+
260+
if has_gte_version("3.0"):
261+
assert window.show_option("pane-border-format") == " #P "
262+
else:
263+
assert (
264+
window.show_option("pane-border-format", scope=OptionScope.Window)
265+
== " #P "
266+
)
247267

248268

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

tests/test_window.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,37 @@ def test_set_and_show_window_options(session: Session) -> None:
266266
window = session.new_window(window_name="test_window")
267267

268268
window.set_option("main-pane-height", 20)
269-
assert window.show_option("main-pane-height") == 20
269+
if has_gte_version("3.0"):
270+
assert window.show_option("main-pane-height") == 20
271+
else:
272+
assert window.show_option("main-pane-height", scope=OptionScope.Window) == 20
270273

271274
window.set_option("main-pane-height", 40)
272-
assert window.show_option("main-pane-height") == 40
275+
276+
if has_gte_version("3.0"):
277+
assert window.show_option("main-pane-height") == 40
278+
else:
279+
assert window.show_option("main-pane-height", scope=OptionScope.Window) == 40
273280

274281
# By default, show-options will session scope, even if target is a window
275282
with pytest.raises(KeyError):
276283
assert window.show_options()["main-pane-height"] == 40
277284

285+
if has_gte_version("3.0"):
286+
assert window.show_option("main-pane-height") == 40
287+
else:
288+
assert window.show_option("main-pane-height", scope=OptionScope.Window) == 40
289+
278290
if has_gte_version("2.3"):
279291
window.set_option("pane-border-format", " #P ")
280-
assert window.show_option("pane-border-format") == " #P "
292+
293+
if has_gte_version("3.0"):
294+
assert window.show_option("pane-border-format") == " #P "
295+
else:
296+
assert (
297+
window.show_option("pane-border-format", scope=OptionScope.Window)
298+
== " #P "
299+
)
281300

282301

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

0 commit comments

Comments
 (0)