Closed fletom closed 7 years ago
@fletom have you figured a way around this?
The issue is being discussed here without a resolution so far https://github.com/pytest-dev/pytest/issues/935
sorry, I couldn't find a nice way to do it so I ended up doing what I wanted without an environment variable at all
After reading pytest-dev/pytest#935 and https://docs.pytest.org/en/latest/writing_plugins.html#hook-function-ordering-call-example, I tried something very simple: I added @pytest.hookimpl(tryfirst=True)
to pytest_load_initial_conftests
(in plugin.py
)... and it works for me, I can set my environment variables before Django settings are loaded 😃
I'll send a PR as soon as possible.
Thanks for the report, @Schnouki - I run into this as well. It would be cool, if the PR can be merged :)
pytest-django's
pytest_load_initial_conftests
method, which imports the Django settings file, runs before pytest-env'spytest_load_initial_conftests
that means that any environment variables which are used in the Django settings module will not be set from pytest-env
is there any way to make sure that pytest-env runs first?