Skip to content

Commit 8963c20

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 c0f2062 commit 8963c20

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/_internal/test_waiter.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -2036,52 +2036,52 @@ def test_invalid_match_type_combinations(wait_pane: Pane) -> None:
20362036
assert "doesn't match patterns" in str(excinfo.value)
20372037

20382038
# Case 2: wait_for_any_content with invalid pattern type for CONTAINS
2039-
with pytest.raises(TypeError) as excinfo:
2039+
with pytest.raises(TypeError) as excinfo_type_error:
20402040
wait_for_any_content(
20412041
wait_pane,
20422042
[123], # type: ignore # Integer not valid for CONTAINS
20432043
ContentMatchType.CONTAINS,
20442044
timeout=0.5,
20452045
)
2046-
assert "must be a string" in str(excinfo.value)
2046+
assert "must be a string" in str(excinfo_type_error.value)
20472047

20482048
# Case 3: wait_for_all_content with empty patterns list
2049-
with pytest.raises(ValueError) as excinfo:
2049+
with pytest.raises(ValueError) as excinfo_empty:
20502050
wait_for_all_content(
20512051
wait_pane,
20522052
[], # Empty patterns list
20532053
ContentMatchType.CONTAINS,
20542054
timeout=0.5,
20552055
)
2056-
assert "At least one content pattern" in str(excinfo.value)
2056+
assert "At least one content pattern" in str(excinfo_empty.value)
20572057

20582058
# Case 4: wait_for_all_content with mismatched lengths
2059-
with pytest.raises(ValueError) as excinfo:
2059+
with pytest.raises(ValueError) as excinfo_mismatch:
20602060
wait_for_all_content(
20612061
wait_pane,
20622062
["pattern1", "pattern2"], # 2 patterns
20632063
[ContentMatchType.CONTAINS], # Only 1 match type
20642064
timeout=0.5,
20652065
)
2066-
assert "match_types list" in str(excinfo.value)
2067-
assert "doesn't match patterns" in str(excinfo.value)
2066+
assert "match_types list" in str(excinfo_mismatch.value)
2067+
assert "doesn't match patterns" in str(excinfo_mismatch.value)
20682068

20692069
# Case 5: wait_for_pane_content with wrong pattern type for PREDICATE
2070-
with pytest.raises(TypeError) as excinfo:
2070+
with pytest.raises(TypeError) as excinfo_predicate:
20712071
wait_for_pane_content(
20722072
wait_pane,
20732073
"not callable", # String not valid for PREDICATE
20742074
ContentMatchType.PREDICATE,
20752075
timeout=0.5,
20762076
)
2077-
assert "must be callable" in str(excinfo.value)
2077+
assert "must be callable" in str(excinfo_predicate.value)
20782078

20792079
# Case 6: Mixed match types with invalid pattern types
2080-
with pytest.raises(TypeError) as excinfo:
2080+
with pytest.raises(TypeError) as excinfo_mixed:
20812081
wait_for_any_content(
20822082
wait_pane,
20832083
["valid string", re.compile(r"\d+"), 123], # type: ignore
20842084
[ContentMatchType.CONTAINS, ContentMatchType.REGEX, ContentMatchType.EXACT],
20852085
timeout=0.5,
20862086
)
2087-
assert "Pattern at index 2" in str(excinfo.value)
2087+
assert "Pattern at index 2" in str(excinfo_mixed.value)

0 commit comments

Comments
 (0)