-
-
Notifications
You must be signed in to change notification settings - Fork 533
How can I set a default value for missing environment variables? #491
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
This works via the env substitution. An example for overriding the tox.ini
envecho.py
output without env set:
output with env set:
|
It's dawning on me, that you might want to set the value of the environment variable itself if it is not set from the outside ... is that right? |
Yes. |
But I'm wondering if I can do something fancy...
|
Fixed the answer after understanding the question properly :) |
Correct :) |
Can I do something like this?
|
AFAIK you can not access the content of env vars in setenv, you can only set them.
I think the correct syntax would be If you start doing magic like this you can always add a thin wrapper to call your tests and do the extra magic there. This is not super elegant but that way you have full flexibility. You can take an ini file with some substitution magic only so far without creating a hideous monster. |
In the case of the But Thank you for your help here! |
Also here: https://stackoverflow.com/questions/42982267/tox-set-default-values-for-missing-environment-variables
I've found that I would really like to use environment variables to control flow - especially when testing. But I also would like to set a default behavior based on whether or not an environment variable is present. In bash, I'd just use: ${ENV_VAR:-default_value}, but I don't have that basic option in Tox (unless I missed it).
Is there a way?
The text was updated successfully, but these errors were encountered: