Metadata-Version: 2.1
Name: pytest-parametrized
Version: 1.4
Summary: Pytest decorator for parametrizing tests with default iterables.
Author-email: Aric Coady <aric.coady@gmail.com>
License: Copyright 2022 Aric Coady
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
             http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        
Project-URL: Homepage, https://github.com/coady/pytest-parametrized
Keywords: pytest,parametrize,parameterize,fixture
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE.txt

[![image](https://img.shields.io/pypi/v/pytest-parametrized.svg)](https://pypi.org/project/pytest-parametrized/)
![image](https://img.shields.io/pypi/pyversions/pytest-parametrized.svg)
[![image](https://pepy.tech/badge/pytest-parametrized)](https://pepy.tech/project/pytest-parametrized)
![image](https://img.shields.io/pypi/status/pytest-parametrized.svg)
[![image](https://github.com/coady/pytest-parametrized/workflows/build/badge.svg)](https://github.com/coady/pytest-parametrized/actions)
[![image](https://codecov.io/gh/coady/pytest-parametrized/branch/main/graph/badge.svg)](https://codecov.io/gh/coady/pytest-parametrized/)
[![image](https://github.com/coady/pytest-parametrized/workflows/codeql/badge.svg)](https://github.com/coady/pytest-parametrized/security/code-scanning)
[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://pypi.org/project/black/)

[Pytest](https://pytest.org/) decorator for parametrizing tests with default iterables, providing alternative syntax for [pytest.mark.parametrize](https://docs.pytest.org/en/latest/how-to/parametrize.html).

# Usage
Decorate tests with iterable default values. Other fixtures can still be used as normal.

## functions
```python
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:
```python
@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:
```python
@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](https://docs.pytest.org/en/latest/how-to/fixtures.html#fixture-parametrize) which simply return their param.

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

Before and after example:
```python
@pytest.fixture(params=[0, 1], ids=["spam", "ham"])
def a(request):
    return request.param

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

# Installation
```console
% pip install pytest-parametrized
```

# Tests
100% branch coverage.

```console
% pytest [--cov]
```

# Changes
1.4
* Python >=3.7 required

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
