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_and_release.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_misc.yml
    test_addition:
      - a: 1
        b: 2
        c: 3
    
      - a: 2
        b: 4
        c: 6
  • Decorate the corresponding test functions with @parametrize_from_file:

    # test_misc.py
    import parametrize_from_file
    
    @parametrize_from_file
    def test_addition(a, b, c):
        assert a + b == c
  • Run pytest as usual:

    $ pytest
    ============================= test session starts ==============================
    platform linux -- Python 3.8.2, pytest-6.2.4, py-1.9.0, pluggy-0.13.1
    rootdir: /home/kale/hacking/projects/parametrize_from_file, configfile: pyproject.toml
    plugins: forked-1.1.3, anyio-3.1.0, xonsh-0.9.27, typeguard-2.12.1, cov-2.8.1, xdist-1.32.0, hypothesis-5.8.3, mock-2.0.0
    collected 1 item
    
    test_misc.py ..                                                          [100%]
    
    ============================== 1 passed in 0.12s ===============================

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

Uploaded Source

Built Distribution

parametrize_from_file-0.17.1-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: parametrize_from_file-0.17.1.tar.gz
  • Upload date:
  • Size: 45.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.3 tqdm/4.65.0 importlib-metadata/6.7.0 keyring/24.0.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.12

File hashes

Hashes for parametrize_from_file-0.17.1.tar.gz
Algorithm Hash digest
SHA256 d336391508b75de6af6c6e7894d16aae3c8a9d4b02db601f4261d6132db50fee
MD5 81d0aaf052d7181d63564312276421d4
BLAKE2b-256 b9237f4d9d3233136ea18074cf72d6262025127a6fe7e685e553b8390ac20de1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: parametrize_from_file-0.17.1-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.3 tqdm/4.65.0 importlib-metadata/6.7.0 keyring/24.0.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.12

File hashes

Hashes for parametrize_from_file-0.17.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4c3d18a28aacb106a3d786d9e02533ccb4b775a1ef92a15365dd407e53e8b427
MD5 9c6cc424a0b7704557a81fae3e8c3d91
BLAKE2b-256 5548472911c59c619c2c6b76591a6e207ae0885e5f043e27f7aa7da0041ba9c0

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