Skip to content

Commit 31e0286

Browse files
authored
Update test_validators.py for Python 3.15a7 (#1530)
matches_re() error message changed in Python 3.15 alpha 7 with the introduction of re.prefixmatch().
1 parent 48b8611 commit 31e0286

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/test_validators.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import re
8+
import sys
89

910
import pytest
1011

@@ -243,10 +244,13 @@ def test_catches_invalid_func(self):
243244
with pytest.raises(ValueError) as ei:
244245
matches_re("a", 0, lambda: None)
245246

246-
assert (
247-
"'func' must be one of None, fullmatch, match, search."
248-
== ei.value.args[0]
249-
)
247+
if sys.version_info >= (3, 15):
248+
errmsg = (
249+
"'func' must be one of None, fullmatch, prefixmatch, search."
250+
)
251+
else:
252+
errmsg = "'func' must be one of None, fullmatch, match, search."
253+
assert errmsg == ei.value.args[0]
250254

251255
@pytest.mark.parametrize(
252256
"func", [None, getattr(re, "fullmatch", None), re.match, re.search]

0 commit comments

Comments
 (0)