Skip to content

Commit dadca89

Browse files
authored
chore: Resolve PytestWarning in test_invalid_args (#557)
1 parent f833e6a commit dadca89

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/unit/test_proxy_configuration.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,17 @@ def test_invalid_arguments() -> None:
7575
(['abc', 'DEF', 'geh$'], 2),
7676
([111, 'DEF', 'geh$'], 2),
7777
]:
78-
with pytest.raises(ValueError, match=re.escape(str(invalid_groups[bad_group_index]))): # type: ignore[index]
78+
bad_group = str(invalid_groups[bad_group_index]) # type: ignore[index]
79+
80+
# Match the actual error message pattern that includes the value and argument name
81+
match_pattern = f'Value {re.escape(bad_group)} of argument groups does not match pattern'
82+
83+
with pytest.raises(ValueError, match=match_pattern):
7984
ProxyConfiguration(groups=invalid_groups) # type: ignore[arg-type]
8085

8186
for invalid_country_code in ['CZE', 'aa', 'DDDD', 1111]:
82-
with pytest.raises(ValueError, match=re.escape(str(invalid_country_code))):
87+
match_pattern = f'Value {re.escape(str(invalid_country_code))} of argument country_code does not match pattern'
88+
with pytest.raises(ValueError, match=match_pattern):
8389
ProxyConfiguration(country_code=invalid_country_code) # type: ignore[arg-type]
8490

8591
with pytest.raises(ValueError, match='Exactly one of .* must be specified'):

0 commit comments

Comments
 (0)