-
-
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
Pytest 4.2.0 seems to break django's @override_settings #4704
Comments
Hi @diox, Thanks for the detailed report, we really appreciate it. I'm happy to investigate this later, meanwhile could you please post a minimal reproducible example if you can? I've zero experience with pytest-django, so would appreciate if @pytest-dev/pytest-django-developers and @pytest-dev/pytest-django-admin could take a look as well. |
@diox |
I'm using Install in a virtualenv with |
pytest-django has a failing test with pytest 4.2 also, caused by the same commit (0f918b1).
|
Maybe pytest-django's method for handling Django unittests needs to be adjusted for the new behavior/code in pytest? |
@diox |
Interesting, it seems to be working without diff --git a/conftest.py b/conftest.py
new file mode 100644
index 0000000..075048d
--- /dev/null
+++ b/conftest.py
@@ -0,0 +1,6 @@
+import pytest
+
+@pytest.mark.trylast
+def pytest_configure():
+ import django
+ django.setup()
diff --git a/requirements.txt b/requirements.txt
index efa3723..b2adbb8 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -8,7 +8,6 @@ pkg-resources==0.0.0
pluggy==0.8.1
py==1.7.0
pytest==4.2.0
-pytest-django==3.4.5
pytz==2018.9
scandir==1.9.0
six==1.12.0 Edit: rolled the patch into a separate branch too. |
Good to know.. so likely a bug/issue caused by pytest-django then. I am releasing pytest-django 3.4.6, which disallows pytest 4.2.0 (I've hoped this could be fixed in pytest 4.2.1, which is still the case maybe, but it might have been better to use |
based on the debugging i'm inclined to close this one as pytest-django issue |
Let's close this then; if further debugging reveals we need to change pytest, we can re-open or create a new issue. 👍 |
It turns out that pytest and pytest-django do a similar thing here, ending in the methods being called twice.
|
Cool finding @blueyed.
|
Upgrading to Pytest 4.2.0 broke our tests: mozilla/addons-server#10556
The issue looked strange - it seemed like django's
@override_settings
persisted from one class to the next instead of being reset, triggering those weird failures. I've bisected it down to 0f918b1 - before that commit, everything works fine.Our pip list is huge, I'm working on a reduced testcase (edit: see #4704 (comment)), but this is with:
I don't think the version of pytest-django matters here, and since I've bisected it down to a pytest commit I'm filing it here.
The text was updated successfully, but these errors were encountered: