Skip to main content

Pytest plugin for parametrizing tests with default iterables.

Project description

image image image image image image image image image

Pytest module for parametrizing tests with default iterables, providing alternative syntax for pytest.mark.parametrize.

Usage

Decorate tests with iterable default values.

functions

from parametrized import parametrized

@parametrized
def test(name=values, ...):
    """test single parametrized arg with each value"""

@parametrized.zip
def test(name=values, name1=values1, ...):
    """test parametrized args with zipped values"""

@parametrized.product
def test(name=values, name1=values1, ...):
    """test parametrized args with cartesian product of values"""

Zip before and after example:

@pytest.mark.parametrize("test_input,expected", [
    ("3+5", 8),
    ("2+4", 6),
    ("6*9", 42),
])
def test_eval(test_input, expected):
    assert eval(test_input) == expected

@parametrized.zip
def test_eval(test_input=["3+5", "2+4", "6*9"], expected=[8, 6, 42]):
    assert eval(test_input) == expected

Product before and after example:

@pytest.mark.parametrize("x", [0, 1])
@pytest.mark.parametrize("y", [2, 3])
def test_foo(x, y):
    pass

@parametrized.product
def test_foo(x=[0, 1], y=[2, 3]):
    pass

fixtures

Parametrized fixtures which simply return their param.

fixture_name = parametrized.fixture(*params, **kwargs)

Before and after example:

@pytest.fixture(params=[0, 1], ids=["spam", "ham"])
def a(request):
    return request.param

a = parametrized.fixture(0, 1, ids=["spam", "ham"])

Installation

% pip install pytest-parametrized

Tests

100% branch coverage.

% pytest [--cov]

Changes

1.3

  • Python >=3.6 required

1.2

  • Namespace plugin removed

1.1

  • pytest 4 compatibility

1.0

  • parametrized keyword options

0.2

  • fixture keyword options

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

pytest-parametrized-1.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

pytest_parametrized-1.3-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest-parametrized-1.3.tar.gz.

File metadata

  • Download URL: pytest-parametrized-1.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pytest-parametrized-1.3.tar.gz
Algorithm Hash digest
SHA256 0075387f0fe98b0bc11db4962308a336ae650f77ac3cde0cd413942c88726ba6
MD5 3ecf3838bce4c2eeaa1d6f54646886dd
BLAKE2b-256 2e16fdd45cd9325a53519015b8caf8137c0aafde3c4186c2b96a7a34c292fd65

See more details on using hashes here.

File details

Details for the file pytest_parametrized-1.3-py3-none-any.whl.

File metadata

  • Download URL: pytest_parametrized-1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.6

File hashes

Hashes for pytest_parametrized-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 69f95e358f5c1817e759f272c042c348f51d065b4eb6cbe45e8d3842228d791f
MD5 1ad5461a93d42210f537aba79f8ee4cb
BLAKE2b-256 9e6dea2f79159348c3a086dc235601b94e2e847ce64f608d181c61b9a79fce81

See more details on using hashes here.

Supported by

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