@@ -469,6 +469,7 @@ def test_stable_baseline_options_and_hooks(server: Server) -> None:
469
469
"split-pane" : "split-window" ,
470
470
"splitp" : "split-window" ,
471
471
}
472
+
472
473
if has_gte_version ("3.2" ):
473
474
terminal_features = server .show_option ("terminal-features" )
474
475
assert isinstance (terminal_features , dict )
@@ -486,7 +487,16 @@ def test_stable_baseline_options_and_hooks(server: Server) -> None:
486
487
if has_gte_version ("3.4" ):
487
488
assert "rxvt*" in terminal_features
488
489
assert terminal_features ["rxvt*" ] == ["ignorefkeys" ]
489
- assert server .show_option ("terminal-overrides" ) is None
490
+
491
+ # Terminal overrides differ by version
492
+ if has_gte_version ("3.0" ):
493
+ assert server .show_option ("terminal-overrides" ) is None
494
+ else :
495
+ terminal_overrides = server .show_option ("terminal-overrides" )
496
+ assert isinstance (terminal_overrides , dict )
497
+ assert "screen*" in terminal_overrides
498
+ assert "xterm*" in terminal_overrides
499
+
490
500
assert server .show_option ("user-keys" ) is None
491
501
assert server .show_option ("status-format" ) is None
492
502
assert server .show_option ("update-environment" ) is None
@@ -529,20 +539,84 @@ def test_complex_option_values(server: Server) -> None:
529
539
session .set_option ("@empty-option" , "" )
530
540
assert session .show_option ("@empty-option" ) == ""
531
541
532
- # Test option inheritance
533
- parent_val = session .show_option ("status-style" )
534
- session .set_option ("status-style" , "fg=red" )
535
- assert session .show_option ("status-style" ) == "fg=red"
536
- assert session .show_option ("status-style" , include_inherited = True ) == "fg=red"
537
- session .unset_option ("status-style" )
538
- assert session .show_option ("status-style" , include_inherited = True ) == parent_val
542
+ # Test option inheritance (only for tmux >= 3.0)
543
+ if has_gte_version ("3.0" ):
544
+ parent_val = session .show_option ("status-style" )
545
+ session .set_option ("status-style" , "fg=red" )
546
+ assert session .show_option ("status-style" ) == "fg=red"
547
+ assert session .show_option ("status-style" , include_inherited = True ) == "fg=red"
548
+ session .unset_option ("status-style" )
549
+ assert session .show_option ("status-style" , include_inherited = True ) == parent_val
550
+
551
+
552
+ def test_style_option_validation (server : Server ) -> None :
553
+ """Test style option validation."""
554
+ session = server .new_session (session_name = "test" )
555
+
556
+ # Valid style (format differs between tmux versions)
557
+ session .set_option ("status-style" , "fg=red,bg=default,bold" )
558
+ style = session .show_option ("status-style" )
559
+ assert isinstance (style , str )
560
+ assert "fg=red" in str (style )
561
+ if has_gte_version ("3.0" ):
562
+ assert "bg=default" in str (style )
563
+ assert "bold" in str (style )
564
+ else :
565
+ assert "bright" in str (style )
566
+
567
+ # Invalid style should raise OptionError
568
+ with pytest .raises (OptionError ):
569
+ session .set_option ("status-style" , "invalid-style" )
570
+
571
+ # Test complex style with multiple attributes (tmux >= 3.0)
572
+ if has_gte_version ("3.0" ):
573
+ session .set_option (
574
+ "status-style" ,
575
+ "fg=colour240,bg=#525252,bold,underscore" ,
576
+ )
577
+ style = session .show_option ("status-style" )
578
+ assert isinstance (style , str )
579
+ assert style == "fg=colour240,bg=#525252,bold,underscore"
580
+
581
+ # Test style with variables
582
+ session .set_option ("status-style" , "fg=#{?pane_in_mode,red,green}" )
583
+ style = session .show_option ("status-style" )
584
+ assert isinstance (style , str )
585
+ assert style == "fg=#{?pane_in_mode,red,green}"
586
+
587
+
588
+ def test_option_error_handling (server : Server ) -> None :
589
+ """Test error handling for options."""
590
+ session = server .new_session (session_name = "test" )
591
+
592
+ # Test invalid/unknown option (tmux 3.0+ returns 'invalid option')
593
+ with pytest .raises (OptionError ) as exc_info :
594
+ session .show_option ("non-existent-option" )
595
+ error_msg = str (exc_info .value ).lower ()
596
+ assert any (msg in error_msg for msg in ["unknown option" , "invalid option" ])
597
+
598
+ # Test invalid option value
599
+ with pytest .raises (OptionError ):
600
+ session .set_option ("aggressive-resize" , "invalid" )
601
+
602
+ # Test ambiguous option (if supported by tmux version)
603
+ if has_gte_version ("2.4" ):
604
+ with pytest .raises (OptionError ) as exc_info :
605
+ # Use a partial name that could match multiple options
606
+ session .show_option (
607
+ "window-"
608
+ ) # Ambiguous: could be window-size, window-style, etc.
609
+ assert "ambiguous option" in str (exc_info .value ).lower ()
539
610
540
611
541
612
def test_terminal_features_edge_cases (
542
613
server : Server ,
543
614
monkeypatch : pytest .MonkeyPatch ,
544
615
) -> None :
545
616
"""Test edge cases for terminal-features option."""
617
+ if not has_gte_version ("3.2" ):
618
+ pytest .skip ("terminal-features requires tmux >= 3.2" )
619
+
546
620
# Test empty features
547
621
monkeypatch .setattr (
548
622
server ,
@@ -587,53 +661,3 @@ def test_terminal_features_edge_cases(
587
661
assert isinstance (xterm_features , list )
588
662
assert any (f == "feature with space" for f in xterm_features )
589
663
assert any (f == "special*char" for f in xterm_features )
590
-
591
-
592
- def test_style_option_validation (server : Server ) -> None :
593
- """Test style option validation."""
594
- session = server .new_session (session_name = "test" )
595
-
596
- # Valid style
597
- session .set_option ("status-style" , "fg=red,bg=default,bold" )
598
- assert session .show_option ("status-style" ) == "fg=red,bg=default,bold"
599
-
600
- # Invalid style should raise OptionError
601
- with pytest .raises (OptionError ):
602
- session .set_option ("status-style" , "invalid-style" )
603
-
604
- # Test complex style with multiple attributes
605
- session .set_option (
606
- "status-style" ,
607
- "fg=colour240,bg=#525252,bold,underscore" ,
608
- )
609
- assert (
610
- session .show_option ("status-style" ) == "fg=colour240,bg=#525252,bold,underscore"
611
- )
612
-
613
- # Test style with variables
614
- session .set_option ("status-style" , "fg=#{?pane_in_mode,red,green}" )
615
- assert session .show_option ("status-style" ) == "fg=#{?pane_in_mode,red,green}"
616
-
617
-
618
- def test_option_error_handling (server : Server ) -> None :
619
- """Test error handling for options."""
620
- session = server .new_session (session_name = "test" )
621
-
622
- # Test invalid/unknown option (tmux 3.0+ returns 'invalid option')
623
- with pytest .raises (OptionError ) as exc_info :
624
- session .show_option ("non-existent-option" )
625
- error_msg = str (exc_info .value ).lower ()
626
- assert any (msg in error_msg for msg in ["unknown option" , "invalid option" ])
627
-
628
- # Test invalid option value
629
- with pytest .raises (OptionError ):
630
- session .set_option ("aggressive-resize" , "invalid" )
631
-
632
- # Test ambiguous option (if supported by tmux version)
633
- if has_gte_version ("2.4" ):
634
- with pytest .raises (OptionError ) as exc_info :
635
- # Use a partial name that could match multiple options
636
- session .show_option (
637
- "window-"
638
- ) # Ambiguous: could be window-size, window-style, etc.
639
- assert "ambiguous option" in str (exc_info .value ).lower ()
0 commit comments