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.18.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

parametrize_from_file-0.18.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for parametrize_from_file-0.18.0.tar.gz
Algorithm Hash digest
SHA256 99813c27b5d696f092d87de4b746c1f1dc8f1c50ea996f0d887f540ab35c7005
MD5 8849b11df130b2ef8392453a194dbae9
BLAKE2b-256 83303e749b8320434dd0eb7c03ff3a3e36f85c50e80ba2aa68fd0648b4f1ed27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for parametrize_from_file-0.18.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a16df2e3e4af954c33f31d3cb5c24636585170fa494a1b4d8b35dc610d01c1cd
MD5 ced77d6c7dd7551cd112ddf9886b376e
BLAKE2b-256 f387ea17a8bad4e1e49a13ed36518c42f0220c1881c80040493055d83382ada6

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page