1010import pytest
1111
1212from libtmux import exc
13- from libtmux .common import has_gte_version , has_lt_version
1413from libtmux .constants import WindowDirection
1514from libtmux .pane import Pane
1615from libtmux .session import Session
@@ -30,9 +29,8 @@ def test_has_session(server: Server, session: Session) -> None:
3029 TEST_SESSION_NAME = session .session_name
3130 assert TEST_SESSION_NAME is not None
3231 assert server .has_session (TEST_SESSION_NAME )
33- if has_gte_version ("2.1" ):
34- assert not server .has_session (TEST_SESSION_NAME [:- 2 ])
35- assert server .has_session (TEST_SESSION_NAME [:- 2 ], exact = False )
32+ assert not server .has_session (TEST_SESSION_NAME [:- 2 ])
33+ assert server .has_session (TEST_SESSION_NAME [:- 2 ], exact = False )
3634 assert not server .has_session ("asdf2314324321" )
3735
3836
@@ -151,11 +149,8 @@ def test_empty_session_option_returns_None(session: Session) -> None:
151149
152150
153151def test_show_option_unknown (session : Session ) -> None :
154- """Session.show_option raises UnknownOption for invalid option."""
155- cmd_exception : type [exc .OptionError ] = exc .UnknownOption
156- if has_gte_version ("3.0" ):
157- cmd_exception = exc .InvalidOption
158- with pytest .raises (cmd_exception ):
152+ """Session.show_option raises InvalidOption for invalid option."""
153+ with pytest .raises (exc .InvalidOption ):
159154 session .show_option ("moooz" )
160155
161156
@@ -172,13 +167,9 @@ def test_set_option_ambiguous(session: Session) -> None:
172167
173168
174169def test_set_option_invalid (session : Session ) -> None :
175- """Session.set_option raises UnknownOption for invalid option."""
176- if has_gte_version ("2.4" ):
177- with pytest .raises (exc .InvalidOption ):
178- session .set_option ("afewewfew" , 43 )
179- else :
180- with pytest .raises (exc .UnknownOption ):
181- session .set_option ("afewewfew" , 43 )
170+ """Session.set_option raises InvalidOption for invalid option."""
171+ with pytest .raises (exc .InvalidOption ):
172+ session .set_option ("afewewfew" , 43 )
182173
183174
184175def test_show_environment (session : Session ) -> None :
@@ -315,10 +306,6 @@ class SessionWindowEnvironmentFixture(t.NamedTuple):
315306]
316307
317308
318- @pytest .mark .skipif (
319- has_lt_version ("3.0" ),
320- reason = "needs -e flag for new-window which was introduced in 3.0" ,
321- )
322309@pytest .mark .parametrize (
323310 list (SessionWindowEnvironmentFixture ._fields ),
324311 SESSION_WINDOW_ENV_FIXTURES ,
@@ -346,34 +333,6 @@ def test_new_window_with_environment(
346333 assert pane .capture_pane ()[- 2 ] == v
347334
348335
349- @pytest .mark .skipif (
350- has_gte_version ("3.0" ),
351- reason = "3.0 has the -e flag on new-window" ,
352- )
353- def test_new_window_with_environment_logs_warning_for_old_tmux (
354- session : Session ,
355- caplog : pytest .LogCaptureFixture ,
356- ) -> None :
357- """Verify new window with environment vars create a warning if tmux is too old."""
358- env = shutil .which ("env" )
359- assert env is not None , "Cannot find usable `env` in PATH."
360-
361- session .new_window (
362- attach = True ,
363- window_name = "window_with_environment" ,
364- window_shell = f"{ env } PS1='$ ' sh" ,
365- environment = {"ENV_VAR" : "window" },
366- )
367-
368- assert any ("Environment flag ignored" in record .msg for record in caplog .records ), (
369- "Warning missing"
370- )
371-
372-
373- @pytest .mark .skipif (
374- has_lt_version ("3.2" ),
375- reason = "Only 3.2+ has the -a and -b flag on new-window" ,
376- )
377336def test_session_new_window_with_direction (
378337 session : Session ,
379338) -> None :
@@ -403,25 +362,6 @@ def test_session_new_window_with_direction(
403362 assert window_before .window_index == "1"
404363
405364
406- @pytest .mark .skipif (
407- has_gte_version ("3.1" ),
408- reason = "Only 3.1 has the -a and -b flag on new-window" ,
409- )
410- def test_session_new_window_with_direction_logs_warning_for_old_tmux (
411- session : Session ,
412- caplog : pytest .LogCaptureFixture ,
413- ) -> None :
414- """Verify new window with direction create a warning if tmux is too old."""
415- session .new_window (
416- window_name = "session_window_with_direction" ,
417- direction = WindowDirection .After ,
418- )
419-
420- assert any ("Direction flag ignored" in record .msg for record in caplog .records ), (
421- "Warning missing"
422- )
423-
424-
425365def test_session_context_manager (server : Server ) -> None :
426366 """Test Session context manager functionality."""
427367 with server .new_session () as session :
0 commit comments