@@ -433,6 +433,91 @@ 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
+ assert server .socket_name is not None
486
+
487
+ monkeypatch .chdir (tmp_path )
488
+ tmuxp_config = pathlib .Path (config_path .format (tmp_path = tmp_path ))
489
+ tmuxp_config .write_text (
490
+ """
491
+ session_name: test
492
+ windows:
493
+ - window_name: test
494
+ panes:
495
+ -
496
+ """ ,
497
+ encoding = "utf-8" ,
498
+ )
499
+
500
+ try :
501
+ cli .cli ([* cli_args , "-d" , "-L" , server .socket_name ])
502
+ except SystemExit :
503
+ pass
504
+
505
+ result = capsys .readouterr ()
506
+ output = "" .join (list (result .out ))
507
+
508
+ if expected_in_out is not None :
509
+ if isinstance (expected_in_out , str ):
510
+ expected_in_out = [expected_in_out ]
511
+ for needle in expected_in_out :
512
+ assert needle in output
513
+
514
+ if expected_not_in_out is not None :
515
+ if isinstance (expected_not_in_out , str ):
516
+ expected_not_in_out = [expected_not_in_out ]
517
+ for needle in expected_not_in_out :
518
+ assert needle not in output
519
+
520
+
436
521
def test_regression_00132_session_name_with_dots (
437
522
tmp_path : pathlib .Path ,
438
523
server : "Server" ,
0 commit comments