-
-
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
RemovedInPytest4Warning via _pytest\compat.py:321 #4131
Comments
In most cases it is inevitable because we still need to test deprecated features. |
I see.. there are more than 130 of them though. |
Hmmm yep, makes sense. |
@nicoddemus this is a bug in plugin factory parsing - we souldnt parse elements that are CompatProperties, or remove those things already |
We shouldn't remove it now, those are scheduled to be removed in 4.1. But I'm OK with just ignoring that for now, TBH. They will go away soon anyway. |
Cool, closing then. |
After all I think it is worth not having a bunch of warnings (that are expected). |
I think it is fine to ignore them by configuring |
Ignoring internal warnings in our own tests seems very risky to me - at some point we'll deprecate something without removing an internal use, and then all downstream test suites using In Hypothesis we get around this with an explicit decorator for all tests that should raise deprecation warnings - it even errors if no warning is emitted. IMO we should also test Pytest with all warnings as errors, except for jobs deliberately testing older versions of dependencies, to make this practical for downstream users. |
I'm seeing these warnings in our project's own pytest runs. I presume this is not expected? Our pytest config is here: |
Oh I meant to ignore the warnings mentioned in this thread explicitly, not all internal warnings, which I agree would be very risky. 👍
We do that already 😉 Lines 206 to 220 in e4871f7
|
That only applies after pytest has finished the
I'm poking at some of these now; I'll update with results when I have some. diff --git a/src/_pytest/warnings.py b/src/_pytest/warnings.py
index 6c4b921..e98d56a 100644
--- a/src/_pytest/warnings.py
+++ b/src/_pytest/warnings.py
@@ -165,8 +165,12 @@ def _issue_config_warning(warning, config):
:param config:
"""
with warnings.catch_warnings(record=True) as records:
- warnings.simplefilter("always", type(warning))
+ # Set this warning to 'always', unless warnings have been configured
+ # at the interpreter level with e.g. -Werror or PYTHONWARNINGS=ignore
+ if sys.warnoptions:
+ warnings.simplefilter("always", type(warning))
warnings.warn(warning, stacklevel=2)
- config.hook.pytest_warning_captured.call_historic(
- kwargs=dict(warning_message=records[0], when="config", item=None)
- )
+ if records:
+ config.hook.pytest_warning_captured.call_historic(
+ kwargs=dict(warning_message=records[0], when="config", item=None)
+ ) Pretty sure this works but the setup to test it is awfully convoluted. I'll leave it there for now before it turns into a serious un-fun slog. |
Awesome, thanks! It is a little tricky to capture the warnings properly during @edmorley, you should not be seeing those warnings unless you or some plugins are accessing those properties. But we have realized that they might be triggered falsely in some test suites, and #4164 fixes this. 👍 |
Thank you for the reply. The problem is that the current warning gives no indication as to what triggered the warning. For example:
Perhaps this is another case of the warning's |
Definitely. #4221 will also help here. |
Created #4236 to adjust the stack level. |
Fixed by #2701 |
There are many RemovedInPytest4Warnings with pytest's own tests, e.g.:
(via https://ci.appveyor.com/project/pytestbot/pytest/builds/19474342/job/c83h5n8ne3snvf8o#L359)
Are those expected?
I would assume pytest should not causes warnings itself.
The text was updated successfully, but these errors were encountered: