1010import pytest
1111
1212from libtmux import exc
13- from libtmux .common import has_gte_version , has_lt_version , has_version
13+ from libtmux .common import has_version
1414from libtmux .pane import Pane
1515from libtmux .server import Server
1616from libtmux .window import Window
@@ -144,10 +144,7 @@ def test_split_window_shell(session: Session) -> None:
144144 assert window .width is not None
145145 assert window .panes [0 ].height is not None
146146 assert float (window .panes [0 ].height ) <= ((float (window .width ) + 1 ) / 2 )
147- if has_gte_version ("3.2" ):
148- assert pane .get ("pane_start_command" , "" ).replace ('"' , "" ) == cmd
149- else :
150- assert pane .get ("pane_start_command" ) == cmd
147+ assert pane .get ("pane_start_command" , "" ).replace ('"' , "" ) == cmd
151148
152149
153150def test_split_window_horizontal (session : Session ) -> None :
@@ -188,30 +185,17 @@ def test_split_window_size(session: Session) -> None:
188185 window = session .new_window (window_name = "split_window window size" )
189186 window .resize (height = 100 , width = 100 )
190187
191- if has_gte_version ("3.1" ):
192- pane = window .split_window (size = 10 )
193- assert pane .pane_height == "10"
188+ pane = window .split_window (size = 10 )
189+ assert pane .pane_height == "10"
194190
195- pane = window .split_window (vertical = False , size = 10 )
196- assert pane .pane_width == "10"
191+ pane = window .split_window (vertical = False , size = 10 )
192+ assert pane .pane_width == "10"
197193
198- pane = window .split_window (size = "10%" )
199- assert pane .pane_height == "8"
194+ pane = window .split_window (size = "10%" )
195+ assert pane .pane_height == "8"
200196
201- pane = window .split_window (vertical = False , size = "10%" )
202- assert pane .pane_width == "8"
203- else :
204- window_height_before = (
205- int (window .window_height ) if isinstance (window .window_height , str ) else 0
206- )
207- window_width_before = (
208- int (window .window_width ) if isinstance (window .window_width , str ) else 0
209- )
210- pane = window .split_window (size = "10%" )
211- assert pane .pane_height == str (int (window_height_before * 0.1 ))
212-
213- pane = window .split_window (vertical = False , size = "10%" )
214- assert pane .pane_width == str (int (window_width_before * 0.1 ))
197+ pane = window .split_window (vertical = False , size = "10%" )
198+ assert pane .pane_width == "8"
215199
216200
217201@pytest .mark .parametrize (
@@ -279,9 +263,8 @@ def test_set_show_window_options(session: Session) -> None:
279263 assert window .show_window_option ("main-pane-height" ) == 40
280264 assert window .show_window_options ()["main-pane-height" ] == 40
281265
282- if has_gte_version ("2.3" ):
283- window .set_window_option ("pane-border-format" , " #P " )
284- assert window .show_window_option ("pane-border-format" ) == " #P "
266+ window .set_window_option ("pane-border-format" , " #P " )
267+ assert window .show_window_option ("pane-border-format" ) == " #P "
285268
286269
287270def test_empty_window_option_returns_None (session : Session ) -> None :
@@ -303,13 +286,10 @@ def test_show_window_option(session: Session) -> None:
303286
304287
305288def test_show_window_option_unknown (session : Session ) -> None :
306- """Window.show_window_option raises UnknownOption for bad option key."""
289+ """Window.show_window_option raises InvalidOption for bad option key."""
307290 window = session .new_window (window_name = "test_window" )
308291
309- cmd_exception : type [exc .OptionError ] = exc .UnknownOption
310- if has_gte_version ("3.0" ):
311- cmd_exception = exc .InvalidOption
312- with pytest .raises (cmd_exception ):
292+ with pytest .raises (exc .InvalidOption ):
313293 window .show_window_option ("moooz" )
314294
315295
@@ -330,15 +310,11 @@ def test_set_window_option_ambiguous(session: Session) -> None:
330310
331311
332312def test_set_window_option_invalid (session : Session ) -> None :
333- """Window.set_window_option raises ValueError for invalid option key."""
313+ """Window.set_window_option raises InvalidOption for invalid option key."""
334314 window = session .new_window (window_name = "test_window" )
335315
336- if has_gte_version ("2.4" ):
337- with pytest .raises (exc .InvalidOption ):
338- window .set_window_option ("afewewfew" , 43 )
339- else :
340- with pytest .raises (exc .UnknownOption ):
341- window .set_window_option ("afewewfew" , 43 )
316+ with pytest .raises (exc .InvalidOption ):
317+ window .set_window_option ("afewewfew" , 43 )
342318
343319
344320def test_move_window (session : Session ) -> None :
@@ -366,10 +342,6 @@ def test_select_layout_accepts_no_arg(server: Server, session: Session) -> None:
366342 window .select_layout ()
367343
368344
369- @pytest .mark .skipif (
370- has_lt_version ("3.2" ),
371- reason = "needs filter introduced in tmux >= 3.2" ,
372- )
373345def test_empty_window_name (session : Session ) -> None :
374346 """New windows can be created with empty string for window name."""
375347 session .set_option ("automatic-rename" , "off" )
@@ -389,10 +361,6 @@ def test_empty_window_name(session: Session) -> None:
389361 assert "''" in cmd .stdout
390362
391363
392- @pytest .mark .skipif (
393- has_lt_version ("3.0" ),
394- reason = "needs -e flag for split-window which was introduced in 3.0" ,
395- )
396364@pytest .mark .parametrize (
397365 "environment" ,
398366 [
@@ -419,26 +387,3 @@ def test_split_window_with_environment(
419387 for k , v in environment .items ():
420388 pane .send_keys (f"echo ${ k } " )
421389 assert pane .capture_pane ()[- 2 ] == v
422-
423-
424- @pytest .mark .skipif (
425- has_gte_version ("3.0" ),
426- reason = "3.0 has the -e flag on split-window" ,
427- )
428- def test_split_window_with_environment_logs_warning_for_old_tmux (
429- session : Session ,
430- caplog : pytest .LogCaptureFixture ,
431- ) -> None :
432- """Verify splitting window with environment variables warns if tmux too old."""
433- env = shutil .which ("env" )
434- assert env is not None , "Cannot find usable `env` in Path."
435-
436- window = session .new_window (window_name = "split_window_with_environment" )
437- window .split_window (
438- shell = f"{ env } PS1='$ ' sh" ,
439- environment = {"ENV_VAR" : "pane" },
440- )
441-
442- assert any ("Environment flag ignored" in record .msg for record in caplog .records ), (
443- "Warning missing"
444- )
0 commit comments