recwarn: warnings are re-emitted with wrong module #11933
Labels
plugin: warnings
related to the warnings builtin plugin
type: bug
problem that needs to be addressed
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:pytest/src/_pytest/recwarn.py
Lines 324 to 331 in aaa9ca7
w
here is awarnings.WarningMessage
sow.__module__
is always"warnings"
. But thewarning.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, themodule
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.cc @reaganjlee @Zac-HD
The text was updated successfully, but these errors were encountered: