Skip to main content

Parametrize test functions with values read from config files.

Project description

https://img.shields.io/pypi/v/parametrize_from_file.svg https://img.shields.io/pypi/pyversions/parametrize_from_file.svg https://img.shields.io/readthedocs/parametrize_from_file.svg https://img.shields.io/github/actions/workflow/status/kalekundert/parametrize_from_file/test.yml?branch=master https://img.shields.io/coveralls/kalekundert/parametrize_from_file.svg https://img.shields.io/github/last-commit/kalekundert/parametrize_from_file?logo=github

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
    test_str_find:
    - str: sir lancelot
      sub: lance
      loc: 4
    
    - str: sir robin
      sub: brave
      loc: -1
  • Decorate the corresponding test functions with @parametrize_from_file:

    # test_camelot.py
    import parametrize_from_file
    
    @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
    
    test_camelot.py ..                                                       [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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file parametrize_from_file-0.20.0.tar.gz.

File metadata

File hashes

Hashes for parametrize_from_file-0.20.0.tar.gz
Algorithm Hash digest
SHA256 b7858b343902fc4ac19ce18ae85a1821f8e82ffcc5f4cc4f4e126d18cd6750be
MD5 b91b125d7bc895b42cb3a57c40c1f9c2
BLAKE2b-256 6447ea83f2dc62293adef669ba5fafe8472b1077fb72e1af548c2b8812da7c16

See more details on using hashes here.

File details

Details for the file parametrize_from_file-0.20.0-py3-none-any.whl.

File metadata

File hashes

Hashes for parametrize_from_file-0.20.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a4575305cb19e8a94d6fc803b40d59ed633601ce3bc9e50ba266342a97907bb
MD5 43ac22a9b55ee9cc0e0557fcf12b5086
BLAKE2b-256 4c33fcb788c78a6dc676c39e669fe166b5901ad9aa5eb7915dee0228f9e10a7d

See more details on using hashes here.

Supported by

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