@@ -433,6 +433,90 @@ def test_load_symlinked_workspace(
433
433
assert pane .current_path == str (realtemp )
434
434
435
435
436
+ if t .TYPE_CHECKING :
437
+ from typing_extensions import TypeAlias
438
+
439
+ ExpectedOutput : TypeAlias = t .Optional [t .Union [str , t .List [str ]]]
440
+
441
+
442
+ class CLILoadFixture (t .NamedTuple ):
443
+ test_id : str
444
+ cli_args : t .List [str ]
445
+ config_path : str
446
+ expected_exit_code : int
447
+ expected_in_out : "ExpectedOutput" = None
448
+ expected_not_in_out : "ExpectedOutput" = None
449
+ expected_in_err : "ExpectedOutput" = None
450
+ expected_not_in_err : "ExpectedOutput" = None
451
+
452
+
453
+ TEST_LOAD_FIXTURES = [
454
+ CLILoadFixture (
455
+ test_id = "exists" ,
456
+ cli_args = ["load" , "." ],
457
+ config_path = "{tmp_path}/.tmuxp.yaml" ,
458
+ expected_exit_code = 0 ,
459
+ expected_in_out = None ,
460
+ expected_not_in_out = None ,
461
+ )
462
+ ]
463
+
464
+
465
+ @pytest .mark .parametrize (
466
+ list (CLILoadFixture ._fields ),
467
+ TEST_LOAD_FIXTURES ,
468
+ ids = [test .test_id for test in TEST_LOAD_FIXTURES ],
469
+ )
470
+ def test_load (
471
+ tmp_path : pathlib .Path ,
472
+ server : "Server" ,
473
+ session : Session ,
474
+ capsys : pytest .CaptureFixture ,
475
+ monkeypatch : pytest .MonkeyPatch ,
476
+ test_id : str ,
477
+ cli_args : t .List [str ],
478
+ config_path : str ,
479
+ expected_exit_code : int ,
480
+ expected_in_out : "ExpectedOutput" ,
481
+ expected_not_in_out : "ExpectedOutput" ,
482
+ expected_in_err : "ExpectedOutput" ,
483
+ expected_not_in_err : "ExpectedOutput" ,
484
+ ) -> None :
485
+ monkeypatch .chdir (tmp_path )
486
+ tmuxp_config = pathlib .Path (config_path .format (tmp_path = tmp_path ))
487
+ print (tmuxp_config )
488
+ tmuxp_config .write_text (
489
+ """
490
+ session_name: test
491
+ windows:
492
+ - window_name: test
493
+ panes:
494
+ -
495
+ """ ,
496
+ encoding = "utf-8" ,
497
+ )
498
+
499
+ try :
500
+ cli .cli ([* cli_args , "-d" , "-L" , server .socket_name ])
501
+ except SystemExit :
502
+ pass
503
+
504
+ result = capsys .readouterr ()
505
+ output = "" .join (list (result .out ))
506
+
507
+ if expected_in_out is not None :
508
+ if isinstance (expected_in_out , str ):
509
+ expected_in_out = [expected_in_out ]
510
+ for needle in expected_in_out :
511
+ assert needle in output
512
+
513
+ if expected_not_in_out is not None :
514
+ if isinstance (expected_not_in_out , str ):
515
+ expected_not_in_out = [expected_not_in_out ]
516
+ for needle in expected_not_in_out :
517
+ assert needle not in output
518
+
519
+
436
520
def test_regression_00132_session_name_with_dots (
437
521
tmp_path : pathlib .Path ,
438
522
server : "Server" ,
0 commit comments