-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
plugin: warningsrelated to the warnings builtin pluginrelated to the warnings builtin plugintype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
While reviewing #11917 I noticed a problem with the warning re-emitting code added in pytest 8.0. I think the module=w.__module__
line below is wrong:
Lines 324 to 331 in aaa9ca7
warnings.warn_explicit( | |
str(w.message), | |
w.message.__class__, # type: ignore[arg-type] | |
w.filename, | |
w.lineno, | |
module=w.__module__, | |
source=w.source, | |
) |
w
here is a warnings.WarningMessage
so w.__module__
is always "warnings"
. But the warning.warn_explicit
say this should rather be the module of the warning that is used for filtering.
If I'm reading the warnings
code correctly, the module
originally passed by the user is not preserved, so the warning cannot be re-emitted faithfully in this regard, but we can probably do something better than the current situation.
Zac-HD, reaganjlee, q-aaronzolnailucas and aaronzoZac-HD and aaronzo
Metadata
Metadata
Assignees
Labels
plugin: warningsrelated to the warnings builtin pluginrelated to the warnings builtin plugintype: bugproblem that needs to be addressedproblem that needs to be addressed