@@ -211,33 +211,53 @@ def test_split_size(session: Session) -> None:
211
211
assert pane .pane_width == str (int (window_width_before * 0.1 ))
212
212
213
213
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
+
214
239
@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 ],
217
243
)
218
244
def test_window_rename (
219
245
session : Session ,
246
+ test_id : str ,
220
247
window_name_before : str ,
248
+ window_name_input : str ,
221
249
window_name_after : str ,
222
250
) -> None :
223
251
"""Test Window.rename_window()."""
224
- window_name_before = "test"
225
- window_name_after = "ha ha ha fjewlkjflwef"
226
-
227
252
session .set_option ("automatic-rename" , "off" )
228
253
window = session .new_window (window_name = window_name_before , attach = True )
229
254
230
255
assert window == session .active_window
231
256
assert window .window_name == window_name_before
232
257
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 )
238
259
239
260
window = session .active_window
240
-
241
261
assert window .window_name == window_name_after
242
262
243
263
@@ -385,24 +405,42 @@ def test_empty_window_name(session: Session) -> None:
385
405
assert "''" in cmd .stdout
386
406
387
407
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
+
388
427
@pytest .mark .skipif (
389
428
has_lt_version ("3.0" ),
390
429
reason = "needs -e flag for split-window which was introduced in 3.0" ,
391
430
)
392
431
@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 ],
398
435
)
399
436
def test_split_with_environment (
400
437
session : Session ,
438
+ test_id : str ,
401
439
environment : dict [str , str ],
402
440
) -> None :
403
441
"""Verify splitting window with environment variables."""
404
442
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 ."
406
444
407
445
window = session .new_window (window_name = "split_with_environment" )
408
446
pane = window .split (
0 commit comments