Skip to main content

Pytest plugin to validate use of envvars on your tests

Project description

See Build Status on Travis CI

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

pytest-envvars-1.2.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_envvars-1.2.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file pytest-envvars-1.2.0.tar.gz.

File metadata

  • Download URL: pytest-envvars-1.2.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pytest-envvars-1.2.0.tar.gz
Algorithm Hash digest
SHA256 b8ca0391fa60d238f9c504b2860510123ac80f4e23125576a87193f094ff5a1e
MD5 9cc5f95c8ccde60f9a4abe353e1da1a4
BLAKE2b-256 72d05bf07215e54b96eba4564ca64f707b9efaf41e404709fc0d1693c6da4da8

See more details on using hashes here.

File details

Details for the file pytest_envvars-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_envvars-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pytest_envvars-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d1b7a699aa3c7d1beb888c1f56dbd89d35bdd0bb1070bd2e78df9e566c9dd7b
MD5 70c29f9f38fa0a9e065d782e06a4ff70
BLAKE2b-256 462199a90b87b5773a3a6b07913f7344500cd73c1fa479d8741f189c8ccd6a8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page