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/workflow/status/kalekundert/parametrize_from_file/Test%20and%20release/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.16.0.tar.gz (44.4 kB view details)

Uploaded Source

Built Distribution

parametrize_from_file-0.16.0-py2.py3-none-any.whl (20.7 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: parametrize_from_file-0.16.0.tar.gz
  • Upload date:
  • Size: 44.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/35.0 requests/2.28.0 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.4 keyring/23.6.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13

File hashes

Hashes for parametrize_from_file-0.16.0.tar.gz
Algorithm Hash digest
SHA256 d6c6724f11f275bb19df8521db42a33e9a5172951e9e4cac5dffe35aea7e5ee4
MD5 79748406a68d36fc7080fe811ff7d1a8
BLAKE2b-256 702c401c176f80ca2f40e555fee78bcbe17a694385bf29fdf447733af18a5842

See more details on using hashes here.

File details

Details for the file parametrize_from_file-0.16.0-py2.py3-none-any.whl.

File metadata

  • Download URL: parametrize_from_file-0.16.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/35.0 requests/2.28.0 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.4 keyring/23.6.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13

File hashes

Hashes for parametrize_from_file-0.16.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 60bbde986ca824e9e6a84fb7fda912a3731cb885c6e4531e2201a60d3088e3b6
MD5 d8ff94e192b09b24a1664a64edd4c433
BLAKE2b-256 193148bb0aaa2f5f5f75b805ff8b44fd449372d99017777beae54477525b33ab

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