-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
-W not working for warnings emitted from finalizer context #8021
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
Comments
"coroutine was never awaited", as well as most ResourceWarnings, occur in finalizer context (from a GC run or reference-count decrement), which can't raise exceptions. That means turning them into errors will just print some stderr, which pytest helpfully suppresses as long as all of your tests pass. If you run with I don't know if it's possible to tell if you're in finalizer context, but if so, perhaps pytest could improve this situation by installing a more intelligent warning filter that remembers that warnings occurred in this context and forces the test to fail. |
I see. Given the lack of options for detecting missing await at lint or test time, it would be great for pytest to improve the warning filter to handle finalizer context. Otherwise I'm grepping the pytest output... |
duplicate of #5676 -- though I think we didn't quite get far enough to figure out that it's the unraisable context there -- let's follow up there! |
I'd like pytest to fail on "coroutine never awaited" RuntimeWarning. But something about these warnings cause pytest not to behave as expected: a matching
-W
spec actually causes the warning to be completely ignored.I suspect it's because these warnings are issued on shutdown of the interpreter, after the pytest harness has exited.The text was updated successfully, but these errors were encountered: