Skip to main content

Parametrize test functions with values read from config files.

Project description

Parametrize From File is a library for reading unit test parameters from config files. It works with the pytest framework. Below is the basic workflow that this package enables:

  • Write test cases in a JSON, YAML, TOML, or NestedText file:

    # test_camelot.yml
    - str: sir lancelot
      sub: lance
      loc: 4
    - str: sir robin
      sub: brave
      loc: -1
  • Decorate the corresponding test functions with @parametrize_from_file:

    import parametrize_from_file
    def test_str_find(str, sub, loc):
        assert str.find(sub) == loc
  • Run pytest as usual:

    ============================= test session starts ==============================
    platform linux -- Python 3.10.0, pytest-7.4.0, pluggy-1.2.0
    rootdir: /home/arthur/holy_grail
    collected 2 items ..                                                       [100%]
    ============================== 2 passed in 0.09s ===============================

Refer to the online documentation for more information.

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

parametrize_from_file-0.20.0.tar.gz (18.9 kB view hashes)

Uploaded Source

Built Distribution

parametrize_from_file-0.20.0-py3-none-any.whl (20.6 kB view hashes)

Uploaded Python 3

Supported by

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