Skip to content

Django Problem with -n 1 #359

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

Open
chebee7i opened this issue Oct 22, 2018 · 2 comments
Open

Django Problem with -n 1 #359

chebee7i opened this issue Oct 22, 2018 · 2 comments
Labels

Comments

@chebee7i
Copy link

When I run pytest with xdist, I get an error that I don't get if I run the same exact command but without the -n 1 flag. Any number of processors specified is sufficient to generate the error.

django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Do I need to do something special to avoid this? When I had this problem previously, it seemed to fix the issue when I put:

[pytest]
addopts = -p no:django

in my pytest.ini. But the problem has come back now. I tried upgrading pytest-django, but it is the same error essentially:

django.core.exceptions.ImproperlyConfigured: Requested settings, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
pytest (3.9.1)
pytest-cov (2.6.0)
pytest-django (3.4.3)
pytest-forked (0.2)
pytest-mock (1.6.3)
pytest-sugar (0.9.1)
pytest-watch (4.2.0)
pytest-xdist (1.23.2)

I understand that I can set DJANGO_SETTINGS_MODULE, but why do I need to? The tests I'm running do not import django at all and if I don't use xdist, then this isn't an issue.

@RonnyPfannschmidt
Copy link
Member

this is due to a massive structural failure of pytest config initialization - the opt out of the django plugin cant currently be passed to xdist worker processes, so things fall appart - see pytest-dev/pytest#1618 and https://github.com/pytest-dev/pytest/projects/2

@chebee7i
Copy link
Author

Thanks, that seems to be it. I'll follow those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants