Update src/_pytest/warning_types.py

Co-authored-by: Florian Bruhin <me@the-compiler.org>
This commit is contained in:
Ronny Pfannschmidt 2022-10-07 12:46:40 +02:00 committed by GitHub
parent 14919c4bbb
commit 7a15bad89b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -168,4 +168,5 @@ def warn_explicit_for(method: FunctionType, message: PytestWarning) -> None:
lineno=lineno,
)
except Warning as w:
# If warnings are errors (e.g. -Werror), location information gets lost, so we add it to the message.
raise type(w)(f"{w}\n at {filename}:{lineno}") from None