-
Notifications
You must be signed in to change notification settings - Fork 346
Multiple django.setup() calls break other plugins #531
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
Thanks for the report. It would be nice to have a failing test case for pytest-django itself as a first step. |
Here is a testcase to show the problem : #538 I tested it against python2.7 and Django==1.11.6, sorry I couldn't use the whole test suite or tox locally since there are lots of breakages on windows (something to do with file locking on DB removal). Basically django.setup() should be idempotent, but in the meantime a workaround can be added here (I talk with django devs about this evolution). |
For reference, the ticket on Django side : https://code.djangoproject.com/ticket/28752#ticket |
There is |
Is it the same thing ? It looks like "settings.configured" is to say that a source of settings has been specified, not that django.setup() has been called, but it's fuzzy for me : https://docs.djangoproject.com/en/1.11/topics/settings/#either-configure-or-django-settings-module-is-required |
I am not sure, but it came to my mind - IIRC pytest-django has checks for this at least.. haven't looked at the code, nor do I remember it apparently good enough, sorry. /cc @pelme |
Please test/review #629. |
In pytest-django hooks, _setup_django() is called multiple times, in conftest setup and as a a trylast, and it leads to multiple resets of logging config (driven by django LOGGING setting).
Inbetween these calls, other plugins like pytest-capturelog try to setup their own logging handlers, but these get reset. I've monkey patched like below, but I guess _setup_django() could use a flag to prevent its multiple execution.
The text was updated successfully, but these errors were encountered: