@@ -211,33 +211,53 @@ def test_split_size(session: Session) -> None:
211211 assert pane .pane_width == str (int (window_width_before * 0.1 ))
212212
213213
214+ class WindowRenameFixture (t .NamedTuple ):
215+ """Test fixture for window rename functionality."""
216+
217+ test_id : str
218+ window_name_before : str
219+ window_name_input : str
220+ window_name_after : str
221+
222+
223+ WINDOW_RENAME_FIXTURES : list [WindowRenameFixture ] = [
224+ WindowRenameFixture (
225+ test_id = "rename_with_spaces" ,
226+ window_name_before = "test" ,
227+ window_name_input = "ha ha ha fjewlkjflwef" ,
228+ window_name_after = "ha ha ha fjewlkjflwef" ,
229+ ),
230+ WindowRenameFixture (
231+ test_id = "rename_with_escapes" ,
232+ window_name_before = r"hello \ wazzup 0" ,
233+ window_name_input = r"hello \ wazzup 0" ,
234+ window_name_after = r"hello \\ wazzup 0" ,
235+ ),
236+ ]
237+
238+
214239@pytest .mark .parametrize (
215- ("window_name_before" , "window_name_after" ),
216- [("test" , "ha ha ha fjewlkjflwef" ), ("test" , "hello \\ wazzup 0" )],
240+ list (WindowRenameFixture ._fields ),
241+ WINDOW_RENAME_FIXTURES ,
242+ ids = [test .test_id for test in WINDOW_RENAME_FIXTURES ],
217243)
218244def test_window_rename (
219245 session : Session ,
246+ test_id : str ,
220247 window_name_before : str ,
248+ window_name_input : str ,
221249 window_name_after : str ,
222250) -> None :
223251 """Test Window.rename_window()."""
224- window_name_before = "test"
225- window_name_after = "ha ha ha fjewlkjflwef"
226-
227252 session .set_option ("automatic-rename" , "off" )
228253 window = session .new_window (window_name = window_name_before , attach = True )
229254
230255 assert window == session .active_window
231256 assert window .window_name == window_name_before
232257
233- window .rename_window (window_name_after )
234-
235- window = session .active_window
236-
237- assert window .window_name == window_name_after
258+ window .rename_window (window_name_input )
238259
239260 window = session .active_window
240-
241261 assert window .window_name == window_name_after
242262
243263
@@ -385,24 +405,42 @@ def test_empty_window_name(session: Session) -> None:
385405 assert "''" in cmd .stdout
386406
387407
408+ class WindowSplitEnvironmentFixture (t .NamedTuple ):
409+ """Test fixture for window split with environment variables."""
410+
411+ test_id : str
412+ environment : dict [str , str ]
413+
414+
415+ WINDOW_SPLIT_ENV_FIXTURES : list [WindowSplitEnvironmentFixture ] = [
416+ WindowSplitEnvironmentFixture (
417+ test_id = "single_env_var" ,
418+ environment = {"ENV_VAR" : "pane" },
419+ ),
420+ WindowSplitEnvironmentFixture (
421+ test_id = "multiple_env_vars" ,
422+ environment = {"ENV_VAR_1" : "pane_1" , "ENV_VAR_2" : "pane_2" },
423+ ),
424+ ]
425+
426+
388427@pytest .mark .skipif (
389428 has_lt_version ("3.0" ),
390429 reason = "needs -e flag for split-window which was introduced in 3.0" ,
391430)
392431@pytest .mark .parametrize (
393- "environment" ,
394- [
395- {"ENV_VAR" : "pane" },
396- {"ENV_VAR_1" : "pane_1" , "ENV_VAR_2" : "pane_2" },
397- ],
432+ list (WindowSplitEnvironmentFixture ._fields ),
433+ WINDOW_SPLIT_ENV_FIXTURES ,
434+ ids = [test .test_id for test in WINDOW_SPLIT_ENV_FIXTURES ],
398435)
399436def test_split_with_environment (
400437 session : Session ,
438+ test_id : str ,
401439 environment : dict [str , str ],
402440) -> None :
403441 """Verify splitting window with environment variables."""
404442 env = shutil .which ("env" )
405- assert env is not None , "Cannot find usable `env` in Path ."
443+ assert env is not None , "Cannot find usable `env` in PATH ."
406444
407445 window = session .new_window (window_name = "split_with_environment" )
408446 pane = window .split (
0 commit comments