Look at os.environ before early_config by blueyed · Pull Request #199 · pytest-dev/pytest-django (original) (raw)
I think the --ds/env/ini-way is useful in libs where you don't typically define DJANGO_SETTINGS_MODULE in your local environment but expect the ini file to provide it. Then it becomes easy for a single contributor to run tests with a specific test setting most of the time, but then just override it with --ds
.
For projects where you use the DJANGO_SETTINGS_MODULE env var in your local environment to run django-admin runserver
and other stuff, having the ini-file override the env var makes more sense. You typically have a settings module for development and one for running tests, not multiple settings modules for tests.
I am split by this - this is more convenient for libs (like pytest-django itself) but not for my "real" project. :)
I am thinking about having another ini-style config that you could specify the order yourself (something like django_settings_module_source = option,ini,env
) - but that seems kind of overkill too.
I agree that addopts = --ds=foo
is a bit of a hack, but so is addopts itself but yet it is practically very useful. :)
@blopker Please let us know if addopts makes it work for you, if not
@blueyed Do you have any thoughts on this?
(If anyone else is reading this and got bitten by this, please drop a line here and let us know!)