Skip to content

Commit 40dfe15

Browse files
committed
fix(tests): resolve type annotation issues in match type tests
Fix type annotation issues in test_invalid_match_type_combinations by using unique variable names for each pytest.raises context manager to avoid type conflicts. This resolves mypy errors related to incompatible exception types in assignments.
1 parent 492a8b1 commit 40dfe15

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

tests/_internal/test_waiter.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,14 +2021,14 @@ def test_wait_for_pane_content_whitespace(wait_pane: Pane) -> None:
20212021

20222022
def test_invalid_match_type_combinations(wait_pane: Pane) -> None:
20232023
"""Test various invalid match type combinations for wait functions.
2024-
2024+
20252025
This comprehensive test validates that appropriate errors are raised
20262026
when invalid combinations of patterns and match types are provided.
20272027
"""
20282028
# Prepare the pane
20292029
wait_pane.send_keys("clear", enter=True)
20302030
wait_until_pane_ready(wait_pane, timeout=2.0)
2031-
2031+
20322032
# Case 1: wait_for_any_content with mismatched lengths
20332033
with pytest.raises(ValueError) as excinfo:
20342034
wait_for_any_content(
@@ -2039,54 +2039,54 @@ def test_invalid_match_type_combinations(wait_pane: Pane) -> None:
20392039
)
20402040
assert "match_types list" in str(excinfo.value)
20412041
assert "doesn't match patterns" in str(excinfo.value)
2042-
2042+
20432043
# Case 2: wait_for_any_content with invalid pattern type for CONTAINS
2044-
with pytest.raises(TypeError) as excinfo:
2044+
with pytest.raises(TypeError) as excinfo_type_error:
20452045
wait_for_any_content(
20462046
wait_pane,
20472047
[123], # type: ignore # Integer not valid for CONTAINS
20482048
ContentMatchType.CONTAINS,
20492049
timeout=0.5,
20502050
)
2051-
assert "must be a string" in str(excinfo.value)
2052-
2051+
assert "must be a string" in str(excinfo_type_error.value)
2052+
20532053
# Case 3: wait_for_all_content with empty patterns list
2054-
with pytest.raises(ValueError) as excinfo:
2054+
with pytest.raises(ValueError) as excinfo_empty:
20552055
wait_for_all_content(
20562056
wait_pane,
20572057
[], # Empty patterns list
20582058
ContentMatchType.CONTAINS,
20592059
timeout=0.5,
20602060
)
2061-
assert "At least one content pattern" in str(excinfo.value)
2062-
2061+
assert "At least one content pattern" in str(excinfo_empty.value)
2062+
20632063
# Case 4: wait_for_all_content with mismatched lengths
2064-
with pytest.raises(ValueError) as excinfo:
2064+
with pytest.raises(ValueError) as excinfo_mismatch:
20652065
wait_for_all_content(
20662066
wait_pane,
20672067
["pattern1", "pattern2"], # 2 patterns
20682068
[ContentMatchType.CONTAINS], # Only 1 match type
20692069
timeout=0.5,
20702070
)
2071-
assert "match_types list" in str(excinfo.value)
2072-
assert "doesn't match patterns" in str(excinfo.value)
2073-
2071+
assert "match_types list" in str(excinfo_mismatch.value)
2072+
assert "doesn't match patterns" in str(excinfo_mismatch.value)
2073+
20742074
# Case 5: wait_for_pane_content with wrong pattern type for PREDICATE
2075-
with pytest.raises(TypeError) as excinfo:
2075+
with pytest.raises(TypeError) as excinfo_predicate:
20762076
wait_for_pane_content(
20772077
wait_pane,
20782078
"not callable", # String not valid for PREDICATE
20792079
ContentMatchType.PREDICATE,
20802080
timeout=0.5,
20812081
)
2082-
assert "must be callable" in str(excinfo.value)
2083-
2082+
assert "must be callable" in str(excinfo_predicate.value)
2083+
20842084
# Case 6: Mixed match types with invalid pattern types
2085-
with pytest.raises(TypeError) as excinfo:
2085+
with pytest.raises(TypeError) as excinfo_mixed:
20862086
wait_for_any_content(
20872087
wait_pane,
20882088
["valid string", re.compile(r"\d+"), 123], # type: ignore
20892089
[ContentMatchType.CONTAINS, ContentMatchType.REGEX, ContentMatchType.EXACT],
20902090
timeout=0.5,
20912091
)
2092-
assert "Pattern at index 2" in str(excinfo.value)
2092+
assert "Pattern at index 2" in str(excinfo_mixed.value)

0 commit comments

Comments
 (0)