3 ms·
Ask HN: Is there Python package that can read environment variables
pytest-mongodb
https://github.com/mdomke/pytest-mongodb#migration-from-humongous
requires 3 variables to be defined in pytest.ini these variables are already used in the code as environment variables. It doesn't make sense to duplicate the code in pytest.ini
I saw that https://pypi.org/project/pytest-env/ let's you define environment variables but this isn't very intelligent since it's only one way. I want it to read and in pytest.ini e.g
[pytest]
x=$blah
Are there any packages that can do this?
- Godel_unicode 5y agoYou can read environment variables via os in the cpython standard library: os.environ["VARIABLE_NAME"]
- zikohh 5y agoBut you can't run this in the pytest.ini I know I can add a fixture and do what you said but I want to do this inside the ini file. Similar to what tox has with passenv