Pytest plugin to validate use of envvars on your tests
Project description
Pytest plugin to validate use of envvars on your tests
What is pytest-envvars?
pytest-envvars randomize values of environment variables on your unit tests to check consistency of mocks about configuration. If the test has a wrong mock, this test will be broken.
Install
$ pip install pytest-envvars
Use
You need write some changes on pytest.ini file, like that…
[pytest]
pytestenvvars__env_files =
.env
pytestenvvars__dont_randomize_envvars =
CACHE_URL
On this example above the plugin read .env file (from pytestenvvars__env_files section) of your project and randomize ALL envvar configuration on that file, if you dont need randomize some envvar configuration you need add this envvar to pytestenvvars__dont_randomize_envvars section like shown above.
Before that configuration to run validation you need run pytest with flag --validate-envvars, like that…
pytest --validate-envvars
To debug purpose you can use --envvars-value to set a default value for all envvars. This parameter accept only two options 0 or 1, see this example:
pytest --validate-envvars --envvars-value=0
Using the plugin that way you will apply the value 0 to ALL of your envvars.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_envvars-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d1b7a699aa3c7d1beb888c1f56dbd89d35bdd0bb1070bd2e78df9e566c9dd7b |
|
MD5 | 70c29f9f38fa0a9e065d782e06a4ff70 |
|
BLAKE2b-256 | 462199a90b87b5773a3a6b07913f7344500cd73c1fa479d8741f189c8ccd6a8e |