@@ -2012,3 +2012,76 @@ def test_wait_for_pane_content_whitespace(wait_pane: Pane) -> None:
20122012 assert result .success
20132013 assert result .matched_content is not None
20142014 assert " " in result .matched_content
2015+
2016+
2017+ def test_invalid_match_type_combinations (wait_pane : Pane ) -> None :
2018+ """Test various invalid match type combinations for wait functions.
2019+
2020+ This comprehensive test validates that appropriate errors are raised
2021+ when invalid combinations of patterns and match types are provided.
2022+ """
2023+ # Prepare the pane
2024+ wait_pane .send_keys ("clear" , enter = True )
2025+ wait_until_pane_ready (wait_pane , timeout = 2.0 )
2026+
2027+ # Case 1: wait_for_any_content with mismatched lengths
2028+ with pytest .raises (ValueError ) as excinfo :
2029+ wait_for_any_content (
2030+ wait_pane ,
2031+ ["pattern1" , "pattern2" , "pattern3" ], # 3 patterns
2032+ [ContentMatchType .CONTAINS , ContentMatchType .REGEX ], # Only 2 match types
2033+ timeout = 0.5 ,
2034+ )
2035+ assert "match_types list" in str (excinfo .value )
2036+ assert "doesn't match patterns" in str (excinfo .value )
2037+
2038+ # Case 2: wait_for_any_content with invalid pattern type for CONTAINS
2039+ with pytest .raises (TypeError ) as excinfo_type_error :
2040+ wait_for_any_content (
2041+ wait_pane ,
2042+ [123 ], # type: ignore # Integer not valid for CONTAINS
2043+ ContentMatchType .CONTAINS ,
2044+ timeout = 0.5 ,
2045+ )
2046+ assert "must be a string" in str (excinfo_type_error .value )
2047+
2048+ # Case 3: wait_for_all_content with empty patterns list
2049+ with pytest .raises (ValueError ) as excinfo_empty :
2050+ wait_for_all_content (
2051+ wait_pane ,
2052+ [], # Empty patterns list
2053+ ContentMatchType .CONTAINS ,
2054+ timeout = 0.5 ,
2055+ )
2056+ assert "At least one content pattern" in str (excinfo_empty .value )
2057+
2058+ # Case 4: wait_for_all_content with mismatched lengths
2059+ with pytest .raises (ValueError ) as excinfo_mismatch :
2060+ wait_for_all_content (
2061+ wait_pane ,
2062+ ["pattern1" , "pattern2" ], # 2 patterns
2063+ [ContentMatchType .CONTAINS ], # Only 1 match type
2064+ timeout = 0.5 ,
2065+ )
2066+ assert "match_types list" in str (excinfo_mismatch .value )
2067+ assert "doesn't match patterns" in str (excinfo_mismatch .value )
2068+
2069+ # Case 5: wait_for_pane_content with wrong pattern type for PREDICATE
2070+ with pytest .raises (TypeError ) as excinfo_predicate :
2071+ wait_for_pane_content (
2072+ wait_pane ,
2073+ "not callable" , # String not valid for PREDICATE
2074+ ContentMatchType .PREDICATE ,
2075+ timeout = 0.5 ,
2076+ )
2077+ assert "must be callable" in str (excinfo_predicate .value )
2078+
2079+ # Case 6: Mixed match types with invalid pattern types
2080+ with pytest .raises (TypeError ) as excinfo_mixed :
2081+ wait_for_any_content (
2082+ wait_pane ,
2083+ ["valid string" , re .compile (r"\d{100}" ), 123_000_928_122 ], # type: ignore
2084+ [ContentMatchType .CONTAINS , ContentMatchType .REGEX , ContentMatchType .EXACT ],
2085+ timeout = 0.5 ,
2086+ )
2087+ assert "Pattern at index 2" in str (excinfo_mixed .value )
0 commit comments