-
Notifications
You must be signed in to change notification settings - Fork 347
pytest==6.1.0: processing filter warnings is done before django.setup() #874
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
Right, pytest now handles the warnings earlier, which means django doesn't get to init yet. But we didn't except warning types to rely on that. IMO you should consider resolving this on your side -- instead of defining |
Yes you're right I am able to dodge the bug by doing so :) However I think they're might still be ground for a fix there, as the exception is highly unexpected and difficult to traceback. Could be a way to introduce |
I think we can probably improve the error message, but I don't think we can fix it -- the idea of the pytest change was exactly to set up the warnings before everything else. I'll close this issue and open a pytest issue to track improving the error. |
Okay thanks for the head's up ;) |
I could be wrong but I believe that even if the pytest bug was to be solved (and the import would not outright crash pytest), we would still end up with the warning filters not installed. I believe that in order for this to work, we need to somehow call django.setup() earlier, and that might be something to solve in pytest-django... Meanwhile, I haven't found a practical example where moving the warning definitions higher in the package, in a module without import-time side effects didn't do the trick, so it's also perfectly fine to keep this as the official solution (I fear the day where the problematic warning import will be in a 3rd party, though). Should we document this in pytest-django ? Or somehow try and solve this ? |
Lauching pytest results in the following error:
pytest test_foo.py click to expand
The project is straighforward.
We created the following Warning and Model:
And use the following
setup.cfg
:The bug was introduced by
pytest==6.1.0
, it worked fine withpytest==6.0.2
.We get that it seems to be introduced by pytest itself, but as its django-related, we assume that the fix will be in
pytest-django
.We would guess from the changelog that it's linked to this issue : pytest-dev/pytest#6681
The text was updated successfully, but these errors were encountered: