1212
1313from libtmux import exc
1414from libtmux ._internal .query_list import ObjectDoesNotExist
15- from libtmux .common import has_gte_version , has_lt_version , has_lte_version
1615from libtmux .constants import (
1716 PaneDirection ,
1817 ResizeAdjustmentDirection ,
@@ -158,12 +157,8 @@ def test_split_shell(session: Session) -> None:
158157 assert window .window_width is not None
159158
160159 assert float (first_pane .pane_height ) <= ((float (window .window_width ) + 1 ) / 2 )
161- if has_gte_version ("3.2" ):
162- pane_start_command = pane .pane_start_command or ""
163- assert pane_start_command .replace ('"' , "" ) == cmd
164-
165- else :
166- assert pane .pane_start_command == cmd
160+ pane_start_command = pane .pane_start_command or ""
161+ assert pane_start_command .replace ('"' , "" ) == cmd
167162
168163
169164def test_split_horizontal (session : Session ) -> None :
@@ -187,30 +182,17 @@ def test_split_size(session: Session) -> None:
187182 window = session .new_window (window_name = "split window size" )
188183 window .resize (height = 100 , width = 100 )
189184
190- if has_gte_version ("3.1" ):
191- pane = window .split (size = 10 )
192- assert pane .pane_height == "10"
193-
194- pane = window .split (direction = PaneDirection .Right , size = 10 )
195- assert pane .pane_width == "10"
185+ pane = window .split (size = 10 )
186+ assert pane .pane_height == "10"
196187
197- pane = window .split (size = "10%" )
198- assert pane .pane_height == "8 "
188+ pane = window .split (direction = PaneDirection . Right , size = 10 )
189+ assert pane .pane_width == "10 "
199190
200- pane = window .split (direction = PaneDirection .Right , size = "10%" )
201- assert pane .pane_width == "8"
202- else :
203- window_height_before = (
204- int (window .window_height ) if isinstance (window .window_height , str ) else 0
205- )
206- window_width_before = (
207- int (window .window_width ) if isinstance (window .window_width , str ) else 0
208- )
209- pane = window .split (size = "10%" )
210- assert pane .pane_height == str (int (window_height_before * 0.1 ))
191+ pane = window .split (size = "10%" )
192+ assert pane .pane_height == "8"
211193
212- pane = window .split (direction = PaneDirection .Right , size = "10%" )
213- assert pane .pane_width == str ( int ( window_width_before * 0.1 ))
194+ pane = window .split (direction = PaneDirection .Right , size = "10%" )
195+ assert pane .pane_width == "8"
214196
215197
216198class WindowRenameFixture (t .NamedTuple ):
@@ -297,9 +279,8 @@ def test_set_show_window_options(session: Session) -> None:
297279 assert window .show_window_option ("main-pane-height" ) == 40
298280 assert window .show_window_options ()["main-pane-height" ] == 40
299281
300- if has_gte_version ("2.3" ):
301- window .set_window_option ("pane-border-format" , " #P " )
302- assert window .show_window_option ("pane-border-format" ) == " #P "
282+ window .set_window_option ("pane-border-format" , " #P " )
283+ assert window .show_window_option ("pane-border-format" ) == " #P "
303284
304285
305286def test_empty_window_option_returns_None (session : Session ) -> None :
@@ -321,13 +302,10 @@ def test_show_window_option(session: Session) -> None:
321302
322303
323304def test_show_window_option_unknown (session : Session ) -> None :
324- """Window.show_window_option raises UnknownOption for bad option key."""
305+ """Window.show_window_option raises InvalidOption for bad option key."""
325306 window = session .new_window (window_name = "test_window" )
326307
327- cmd_exception : type [exc .OptionError ] = exc .UnknownOption
328- if has_gte_version ("3.0" ):
329- cmd_exception = exc .InvalidOption
330- with pytest .raises (cmd_exception ):
308+ with pytest .raises (exc .InvalidOption ):
331309 window .show_window_option ("moooz" )
332310
333311
@@ -348,15 +326,11 @@ def test_set_window_option_ambiguous(session: Session) -> None:
348326
349327
350328def test_set_window_option_invalid (session : Session ) -> None :
351- """Window.set_window_option raises ValueError for invalid option key."""
329+ """Window.set_window_option raises InvalidOption for invalid option key."""
352330 window = session .new_window (window_name = "test_window" )
353331
354- if has_gte_version ("2.4" ):
355- with pytest .raises (exc .InvalidOption ):
356- window .set_window_option ("afewewfew" , 43 )
357- else :
358- with pytest .raises (exc .UnknownOption ):
359- window .set_window_option ("afewewfew" , 43 )
332+ with pytest .raises (exc .InvalidOption ):
333+ window .set_window_option ("afewewfew" , 43 )
360334
361335
362336def test_move_window (session : Session ) -> None :
@@ -384,10 +358,6 @@ def test_select_layout_accepts_no_arg(server: Server, session: Session) -> None:
384358 window .select_layout ()
385359
386360
387- @pytest .mark .skipif (
388- has_lt_version ("3.2" ),
389- reason = "needs filter introduced in tmux >= 3.2" ,
390- )
391361def test_empty_window_name (session : Session ) -> None :
392362 """New windows can be created with empty string for window name."""
393363 session .set_option ("automatic-rename" , "off" )
@@ -426,10 +396,6 @@ class WindowSplitEnvironmentFixture(t.NamedTuple):
426396]
427397
428398
429- @pytest .mark .skipif (
430- has_lt_version ("3.0" ),
431- reason = "needs -e flag for split-window which was introduced in 3.0" ,
432- )
433399@pytest .mark .parametrize (
434400 list (WindowSplitEnvironmentFixture ._fields ),
435401 WINDOW_SPLIT_ENV_FIXTURES ,
@@ -457,10 +423,6 @@ def test_split_with_environment(
457423 assert pane .capture_pane ()[- 2 ] == v
458424
459425
460- @pytest .mark .skipif (
461- has_lte_version ("3.1" ),
462- reason = "3.2 has the -Z flag on split-window" ,
463- )
464426def test_split_window_zoom (
465427 session : Session ,
466428) -> None :
@@ -483,33 +445,6 @@ def test_split_window_zoom(
483445 assert pane_with_zoom .height == pane_with_zoom .window_height
484446
485447
486- @pytest .mark .skipif (
487- has_gte_version ("3.0" ),
488- reason = "3.0 has the -e flag on split-window" ,
489- )
490- def test_split_with_environment_logs_warning_for_old_tmux (
491- session : Session ,
492- caplog : pytest .LogCaptureFixture ,
493- ) -> None :
494- """Verify splitting window with environment variables warns if tmux too old."""
495- env = shutil .which ("env" )
496- assert env is not None , "Cannot find usable `env` in Path."
497-
498- window = session .new_window (window_name = "split_with_environment" )
499- window .split (
500- shell = f"{ env } PS1='$ ' sh" ,
501- environment = {"ENV_VAR" : "pane" },
502- )
503-
504- assert any ("Environment flag ignored" in record .msg for record in caplog .records ), (
505- "Warning missing"
506- )
507-
508-
509- @pytest .mark .skipif (
510- has_lt_version ("2.9" ),
511- reason = "resize-window only exists in tmux 2.9+" ,
512- )
513448def test_resize (
514449 session : Session ,
515450) -> None :
@@ -586,10 +521,6 @@ def test_resize(
586521 assert window_height_before < window_height_expanded
587522
588523
589- @pytest .mark .skipif (
590- has_lt_version ("3.2" ),
591- reason = "Only 3.2+ has the -a and -b flag on new-window" ,
592- )
593524def test_new_window_with_direction (
594525 session : Session ,
595526) -> None :
@@ -619,32 +550,6 @@ def test_new_window_with_direction(
619550 assert window_before .window_index == "2"
620551
621552
622- @pytest .mark .skipif (
623- has_gte_version ("3.2" ),
624- reason = "Only 3.2+ has the -a and -b flag on new-window" ,
625- )
626- def test_new_window_with_direction_logs_warning_for_old_tmux (
627- session : Session ,
628- caplog : pytest .LogCaptureFixture ,
629- ) -> None :
630- """Verify new window with direction create a warning if tmux is too old."""
631- window = session .active_window
632- window .refresh ()
633-
634- window .new_window (
635- window_name = "window_with_direction" ,
636- direction = WindowDirection .After ,
637- )
638-
639- assert any ("Window target ignored" in record .msg for record in caplog .records ), (
640- "Warning missing"
641- )
642-
643- assert any ("Direction flag ignored" in record .msg for record in caplog .records ), (
644- "Warning missing"
645- )
646-
647-
648553def test_window_context_manager (session : Session ) -> None :
649554 """Test Window context manager functionality."""
650555 with session .new_window () as window :
0 commit comments