-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
recwarn: warnings are re-emitted with wrong module #11933
Comments
Ah, yeah, we'll need to recover the module name from |
Apologies if I'm missing something. The
|
OK, here's what I think is going on - there are several things with too-similar names and we're getting them mixed up.
So it's going to be imperfect, but we can still improve somewhat on the status quo 🙂 |
Ran into this today - I have a (potentially common) setup where:
@Zac-HD 's solution seems sensible but possibly expensive? I'd like to know in what scenarios that wouldn't work. I'll propose an alternative solution/workaround: Add a kwarg to Line 236 in 9cc6b50
|
I've added a #12897 implementing my idea. Any reviews welcome! |
Added workaround comment to PR (tldr probably just better to make the change on our end than adding user-facing arg) -- I did get to do a benchmark of Zac's solution though and it goes from 1.136 to 1.536 sec summed 10,000 examples so doesn't seem too bad |
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: