Add warning for an empty group in the message string

This commit is contained in:
Allan Olweny 2024-05-18 14:28:36 -04:00
parent 635fbe2bff
commit de96d738eb
1 changed files with 7 additions and 0 deletions

View File

@ -1924,6 +1924,13 @@ def parse_warning_filter(
raise UsageError(error_template.format(error=exception_text)) from None
if message and escape:
message = re.escape(message)
if "()" in message:
warning = dedent(
"""
An empty group '()' will not match a string that contains literal parenthesis
"""
)
warnings.warn(PytestConfigWarning(warning))
if module and escape:
module = re.escape(module) + r"\Z"
if lineno_: