From 7a15bad89b2a11923f06a5ac416303d77f48d05b Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Fri, 7 Oct 2022 12:46:40 +0200 Subject: [PATCH] Update src/_pytest/warning_types.py Co-authored-by: Florian Bruhin --- src/_pytest/warning_types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_pytest/warning_types.py b/src/_pytest/warning_types.py index 388949bed..3be1648fe 100644 --- a/src/_pytest/warning_types.py +++ b/src/_pytest/warning_types.py @@ -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