-
Notifications
You must be signed in to change notification settings - Fork 344
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
Look at os.environ before early_config #199
Conversation
It is not used currently though, see #199.
Yes, it makes sense to change this order and I think it's fine. I have a slight concern about backward incompatibility, this change might break things for someone, but I think that it is worth merging this. |
85393c6
to
038ca82
Compare
aeeef1a
to
62f92fb
Compare
This prefers the current current environment before the config from (e.g.) setup.cfg.
62f92fb
to
976bb56
Compare
This was changed before the 2.9.0 release and was not documented. The change is backward incompatible and may surprise users. Then change was originally made in #199.
@blueyed This broke my own test suite when running soon-to-be-2.9.0-release against my own tests. I've added a note in the changelog in 726a63f. I still think this is a good change, but it was difficult to track down at first when a bunch of unrelated tests random tests just failed in strange ways. Please have a look at the changelog and let me know/feel free to make other changes if you figure out a way to make this more visible/obvious. :) |
We should have information about it with |
A message that prints which Django settings is used? Something like
?? |
Yes, and also the origin of it (e.g. option, environment or config). |
Yes, that makes sense. |
I'll fix it now! |
With the recent change to prefer DJANGO_SETTINGS_MODULE from the environment rather than ini-file, it is nice to show which Django settings is used and why it was choosen. See discussion in #199 for more information.
Fixed in 4b0526e :) |
Thanks! |
This broke our build. We use the environment for running the app then use the ini file to override the environment. This way we can run py.test in any folder to run a subset of tests. Now we have to figure out another way to do this. I guess I don't understand why the change was made. It seems like Django itself always uses the env as a last option. |
The reasoning for this change is that typically the .ini file goes into the repository and sets a default settings module. The env var can be overridden (or set to a default in the local environment). Finally the Would putting
in your ini file solve your problem? That would set the Django settings from the ini-file, but then you cannot override with |
Thank you for the workaround, I'll try it out. All I know is I have a case where having the env last works really well. The I have a feeling this is going to bite a lot of people. Anyway, this has shipped already so I guess I'll just find a way around it. |
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 For projects where you use the DJANGO_SETTINGS_MODULE env var in your local environment to run 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 I agree that @blopker Please let us know if addopts makes it work for you, if not (If anyone else is reading this and got bitten by this, please drop a line here and let us know!) |
I can confirm Aside from changing it back, I'd suggest adding Cheers! |
JFI: my use case was to easily use different settings from the environment, while there might be a default configured in the config file.
I can see this use case, and could imagine to use I also cannot remember if the PR came from working on a project or when working on pytest-django itself. I think a option like A workaround for @blopker's use case would also be to run And after all I'd be OK with changing the default again, of course. |
This was changed before the 2.9.0 release and was not documented. The change is backward incompatible and may surprise users. Then change was originally made in pytest-dev#199.
With the recent change to prefer DJANGO_SETTINGS_MODULE from the environment rather than ini-file, it is nice to show which Django settings is used and why it was choosen. See discussion in pytest-dev#199 for more information.
Changes Unknown when pulling 976bb56 on prefer-django-settings-from-env into * on master*. |
It is not used currently though, see pytest-dev#199.
This prefers the current current environment before the config from (e.g.) setup.cfg. Closes pytest-dev#199
This was changed before the 2.9.0 release and was not documented. The change is backward incompatible and may surprise users. Then change was originally made in pytest-dev#199.
With the recent change to prefer DJANGO_SETTINGS_MODULE from the environment rather than ini-file, it is nice to show which Django settings is used and why it was choosen. See discussion in pytest-dev#199 for more information.
It is not used currently though, see pytest-dev/pytest-django#199.
This prefers the current current environment before the config from (e.g.) setup.cfg. Closes pytest-dev/pytest-django#199
This was changed before the 2.9.0 release and was not documented. The change is backward incompatible and may surprise users. Then change was originally made in pytest-dev/pytest-django#199.
With the recent change to prefer DJANGO_SETTINGS_MODULE from the environment rather than ini-file, it is nice to show which Django settings is used and why it was choosen. See discussion in pytest-dev/pytest-django#199 for more information.
This breaks a lot of internal tests, which could be adjusted.
I think it makes more sense to prefer the current environment before the
config from (e.g.) setup.cfg.