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

Uploaded Source

Built Distribution

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

parametrize_from_file-0.21.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: parametrize_from_file-0.21.0.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for parametrize_from_file-0.21.0.tar.gz
Algorithm Hash digest
SHA256 91e2ac9e433293d76eed31af2616573f61292ea38a933f2fc6b473597c868345
MD5 3f19b4a59a757527c00d8f280c144080
BLAKE2b-256 def7a0eb2c970ceec2ec7107f16b174cde2443e040e197bc797ab19408677c89

See more details on using hashes here.

Provenance

The following attestation bundles were made for parametrize_from_file-0.21.0.tar.gz:

Publisher: release.yml on kalekundert/parametrize_from_file

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for parametrize_from_file-0.21.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edfef8c6662af251780cce9027eca8812315f5702982839877971b6fd82c3e4a
MD5 c70771fd6fa7c1499091b9634019ce8d
BLAKE2b-256 31980b4e2f99d65ecde21a9e7869fd1b761bbc58f9e3ce6fe4ebee7c88e2b512

See more details on using hashes here.

Provenance

The following attestation bundles were made for parametrize_from_file-0.21.0-py3-none-any.whl:

Publisher: release.yml on kalekundert/parametrize_from_file

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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