-
Notifications
You must be signed in to change notification settings - Fork 347
pytest-django fails pytest (django.core.exceptions.ImproperlyConfigured) #599
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
I struggled with these sorts of problems for a bit. Of course you have followed the steps here? After I got my settings and django.setup() in the right place, everything worked fine. Figuring out the right place is somewhat challenging. |
@omegacore I removed the pytest-django from my machine and ran the tests. My question is that why is pytest-django effecting pytest even when there is no need. I don't have django dependency in the project where I am running pytest. |
Ah, I completely misread that. |
What is the full traceback / error there? Just installing pytest and pytest-django, and having tests that do not use Django/pytest-django does not result in any error for me. |
Can you just provide the full traceback/more details yourself first, please? |
I have the same issue in my environment: only some of my modules depend on django, and I have pytest-django installed for these (with
In that module, nothing explicitly imports django.... but pytest-django thinks that we did. After instrumenting
Looks like (in my case) the I'd suggest making the |
@olasd |
… configured Some modules, e.g. hypothesis, load some Django modules for their own fixtures. This means that the `django.conf` module sometimes gets loaded, even though it's never used (and the settings are not initialized). This causes unrelated test failures when pytest_django is installed, as pytest_django considers that having a loaded django.conf means the settings are set up and ready to be modified. The Django settings object provides a flag to check this condition, which we now use. Add a regression test that mimics what hypothesis did which makes pytest-django fail. Closes pytest-dev#599.
… configured Some modules, e.g. hypothesis, load some Django modules for their own fixtures. This means that the `django.conf` module sometimes gets loaded, even though it's never used (and the settings are not initialized). This causes unrelated test failures when pytest_django is installed, as pytest_django considers that having a loaded django.conf means the settings are set up and ready to be modified. The Django settings object provides a flag to check this condition, which we now use. Add a regression test that mimics what hypothesis did which makes pytest-django fail. Closes pytest-dev#599.
@blueyed I noticed that pytest-django already almost tests for the same issue but not quite exactly :) I've adapted my propsoed change to stay as close to the original intent as possible. |
… configured Some modules, e.g. hypothesis, load some Django modules for their own fixtures. This means that the `django.conf` module sometimes gets loaded, even though it's never used (and the settings are not initialized). This causes unrelated test failures when pytest_django is installed, as pytest_django considers that having a loaded django.conf means the settings are set up and ready to be modified. The Django settings object provides a flag to check this condition, which we now use. Add a regression test that mimics what hypothesis did which makes pytest-django fail. Closes pytest-dev#599.
… configured Some modules, e.g. hypothesis, load some Django modules for their own fixtures. This means that the `django.conf` module sometimes gets loaded, even though it's never used (and the settings are not initialized). This causes unrelated test failures when pytest_django is installed, as pytest_django considers that having a loaded django.conf means the settings are set up and ready to be modified. The Django settings object provides a flag to check this condition, which we now use. Add a regression test that mimics what hypothesis did which makes pytest-django fail. Closes pytest-dev#599.
… configured (#668) Some modules, e.g. hypothesis, load some Django modules for their own fixtures. This means that the `django.conf` module sometimes gets loaded, even though it's never used (and the settings are not initialized). This causes unrelated test failures when pytest_django is installed, as pytest_django considers that having a loaded django.conf means the settings are set up and ready to be modified. The Django settings object provides a flag to check this condition, which we now use. Add a regression test that mimics what hypothesis did which makes pytest-django fail. Closes #599.
I don't know whether this is an intended feature or a bug.
I reported it in pytest repo. They asked me to report it here.
The text was updated successfully, but these errors were encountered: