@@ -452,3 +452,87 @@ def test_show_option_pane_fixture(
452
452
assert k in result
453
453
454
454
assert result [k ] == v
455
+
456
+
457
+ class SetOptionDataclassTestFixture (t .NamedTuple ):
458
+ """Test fixture raw set_option(s) data into typed libtmux data."""
459
+
460
+ # pytest internal
461
+ test_id : str
462
+
463
+ # test data
464
+ tmux_option : str # e.g. terminal-features
465
+ tmux_option_value : t .List [str ] # set_option data (raw)
466
+
467
+ # results
468
+ dataclass_attribute : str # e.g. terminal_features
469
+ expected : t .Any # e.g. 50, TerminalFeatures({}), etc.
470
+
471
+
472
+ TEST_SET_OPTION_FIXTURES : t .List [SetOptionDataclassTestFixture ] = [
473
+ SetOptionDataclassTestFixture (
474
+ test_id = "command-alias" ,
475
+ tmux_option = "command-alias" ,
476
+ tmux_option_value = textwrap .dedent (
477
+ """
478
+ command-alias[0] split-pane=split-window
479
+ command-alias[1] splitp=split-window
480
+ command-alias[2] "server-info=show-messages -JT"
481
+ command-alias[3] "info=show-messages -JT"
482
+ command-alias[4] "choose-window=choose-tree -w"
483
+ command-alias[5] "choose-session=choose-tree -s"
484
+ """ ,
485
+ )
486
+ .strip ()
487
+ .split ("\n " ),
488
+ dataclass_attribute = "command_alias" ,
489
+ expected = TmuxArray (
490
+ {
491
+ "split-pane" : "split-window" ,
492
+ "splitp" : "split-window" ,
493
+ "server-info" : "show-messages -JT" ,
494
+ "info" : "show-messages -JT" ,
495
+ "choose-window" : "choose-tree -w" ,
496
+ "choose-session" : "choose-tree -s" ,
497
+ },
498
+ ),
499
+ ),
500
+ ]
501
+
502
+
503
+ @pytest .mark .parametrize (
504
+ list (SetOptionDataclassTestFixture ._fields ),
505
+ TEST_SET_OPTION_FIXTURES ,
506
+ ids = [test .test_id for test in TEST_SET_OPTION_FIXTURES ],
507
+ )
508
+ def test_set_option_pane_fixture (
509
+ test_id : str ,
510
+ tmux_option : str ,
511
+ tmux_option_value : str ,
512
+ dataclass_attribute : str ,
513
+ expected : t .Any ,
514
+ server : "Server" ,
515
+ ) -> None :
516
+ """Test Pane.show_option(s)?."""
517
+ session = server .new_session (session_name = "test" )
518
+ window = session .new_window (window_name = "test" )
519
+ pane = window .split_window (attach = False )
520
+
521
+ pane .set_option (tmux_option , tmux_option_value )
522
+
523
+ result = pane .show_option (tmux_option )
524
+
525
+ assert result == expected
526
+
527
+ if expected is None :
528
+ assert (
529
+ result is not None
530
+ ), f"Expected { expected } to be { type (expected )} , got None"
531
+
532
+ if isinstance (expected , dict ):
533
+ assert isinstance (result , dict ), f'Expected dict, got "{ type (result )} "'
534
+
535
+ for k , v in expected .items ():
536
+ assert k in result
537
+
538
+ assert result [k ] == v
0 commit comments