[![image](https://img.shields.io/pypi/v/pytest-parametrize.svg)](https://pypi.org/project/pytest-parametrize/)
[![image](https://img.shields.io/pypi/pyversions/pytest-parametrize.svg)](https://pypi.org/project/pytest-parametrize/)
[![image](https://img.shields.io/pypi/status/pytest-parametrize.svg)](https://pypi.org/project/pytest-parametrize/)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/MarcinSkrobczynski/pytest-parametrize/build_and_deploy.yml?label=build&logo=github&logoColor=white&style=flat-square)](https://github.com/MarcinSkrobczynski/pytest-parametrize/actions/workflows/build_and_deploy.yml)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?style=flat-square&logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![image](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
# pytest-parametrize
[pytest](https://pytest.org/) decorator for parametrizing test cases in a dict-way.
It is an alternative for the [pytest.mark.parametrize](https://docs.pytest.org/en/latest/how-to/parametrize.html).
## Usage
Decorate test function with test cases defined as a dictionary.
### Example:
#### Simple
```python
import pytest
from pytest_parametrize import parametrize
@parametrize(
{
"test-case-1": {"a": 1, "b": 2, "c": 3},
"test-case-2": {"a": 2, "b": 3, "c": 5},
"test-case-3": [
{"a": 3, "b": 5, "c": 8},
{"a": 5, "b": 8, "c": 13},
{"a": 8, "b": 13, "c": 21},
{"a": 0, "b": 0, "c": 1, "marks": pytest.mark.xfail},
],
},
)
def test_something(a, b, c):
assert a + b == c
```
#### Or more complex one:
```python
from pytest_parametrize import parametrize
@parametrize(
{
"a=1": {"a": 1},
"a=2": {"a": 2},
}
)
@parametrize(
{
"b=1": {"b": 1},
"b=2": {"b": 2},
}
)
def test_parametrize__when_complex_structure(a: int, b: int):
assert a * b > 0
```
### Description
Decorator takes dict, which:
- keys define names of the test cases, and
- values define named arguments in dict manner (or list of such dicts), which are passed to the decorated test function.
## Installation
### pip
```shell
pip install pytest-parametrize
```
### poetry
```shell
poetry add pytest-parametrize
```
# Collaboration
## Test & coverage
```shell
pytest -vvv tests --cov=pytest_parametrize
```
Raw data
{
"_id": null,
"home_page": "https://github.com/MarcinSkrobczynski/pytest-parametrize",
"name": "pytest-parametrize",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "pytest, parametrize, testing",
"author": "Marcin Skrobczy\u0144ski",
"author_email": "marcin@skrobczynski.pl",
"download_url": "https://files.pythonhosted.org/packages/51/d6/ae276667c7bf4b5e3acc8085c915aff03fe15ebd37bac18fef5675cdf5d2/pytest_parametrize-1.3.0.tar.gz",
"platform": null,
"description": "[![image](https://img.shields.io/pypi/v/pytest-parametrize.svg)](https://pypi.org/project/pytest-parametrize/)\n[![image](https://img.shields.io/pypi/pyversions/pytest-parametrize.svg)](https://pypi.org/project/pytest-parametrize/)\n[![image](https://img.shields.io/pypi/status/pytest-parametrize.svg)](https://pypi.org/project/pytest-parametrize/)\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/MarcinSkrobczynski/pytest-parametrize/build_and_deploy.yml?label=build&logo=github&logoColor=white&style=flat-square)](https://github.com/MarcinSkrobczynski/pytest-parametrize/actions/workflows/build_and_deploy.yml)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?style=flat-square&logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)\n[![image](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\n# pytest-parametrize\n\n[pytest](https://pytest.org/) decorator for parametrizing test cases in a dict-way.\nIt is an alternative for the [pytest.mark.parametrize](https://docs.pytest.org/en/latest/how-to/parametrize.html).\n\n## Usage\nDecorate test function with test cases defined as a dictionary.\n\n### Example:\n\n#### Simple\n```python\nimport pytest\nfrom pytest_parametrize import parametrize\n\n@parametrize(\n {\n \"test-case-1\": {\"a\": 1, \"b\": 2, \"c\": 3},\n \"test-case-2\": {\"a\": 2, \"b\": 3, \"c\": 5},\n \"test-case-3\": [\n {\"a\": 3, \"b\": 5, \"c\": 8},\n {\"a\": 5, \"b\": 8, \"c\": 13},\n {\"a\": 8, \"b\": 13, \"c\": 21},\n {\"a\": 0, \"b\": 0, \"c\": 1, \"marks\": pytest.mark.xfail},\n ],\n },\n)\ndef test_something(a, b, c):\n assert a + b == c\n```\n\n#### Or more complex one:\n```python\nfrom pytest_parametrize import parametrize\n\n@parametrize(\n {\n \"a=1\": {\"a\": 1},\n \"a=2\": {\"a\": 2},\n }\n)\n@parametrize(\n {\n \"b=1\": {\"b\": 1},\n \"b=2\": {\"b\": 2},\n }\n)\ndef test_parametrize__when_complex_structure(a: int, b: int):\n assert a * b > 0\n```\n\n### Description\nDecorator takes dict, which:\n- keys define names of the test cases, and\n- values define named arguments in dict manner (or list of such dicts), which are passed to the decorated test function.\n\n## Installation\n\n### pip\n```shell\npip install pytest-parametrize\n```\n\n### poetry\n```shell\npoetry add pytest-parametrize\n```\n\n# Collaboration\n\n## Test & coverage\n```shell\npytest -vvv tests --cov=pytest_parametrize\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "pytest decorator for parametrizing test cases in a dict-way",
"version": "1.3.0",
"project_urls": {
"Homepage": "https://github.com/MarcinSkrobczynski/pytest-parametrize"
},
"split_keywords": [
"pytest",
" parametrize",
" testing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "97c62384eec7692b7dc8345fde23253e8c87335da51a874373091f4f9336b214",
"md5": "234abead58822acdf2b86e01e9d6bb07",
"sha256": "4a202e45c9707d9e04fee4a67f41dd5426ea97d5ba868548505294b462713d2e"
},
"downloads": -1,
"filename": "pytest_parametrize-1.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "234abead58822acdf2b86e01e9d6bb07",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 4357,
"upload_time": "2024-11-10T00:29:17",
"upload_time_iso_8601": "2024-11-10T00:29:17.141840Z",
"url": "https://files.pythonhosted.org/packages/97/c6/2384eec7692b7dc8345fde23253e8c87335da51a874373091f4f9336b214/pytest_parametrize-1.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "51d6ae276667c7bf4b5e3acc8085c915aff03fe15ebd37bac18fef5675cdf5d2",
"md5": "701faaeef4b56a55b02d28a4e9edfa3a",
"sha256": "30d5e59c95466ef9f6f664ac14c6caf22487a7688370ce3edd065fd458ac9892"
},
"downloads": -1,
"filename": "pytest_parametrize-1.3.0.tar.gz",
"has_sig": false,
"md5_digest": "701faaeef4b56a55b02d28a4e9edfa3a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 3974,
"upload_time": "2024-11-10T00:29:18",
"upload_time_iso_8601": "2024-11-10T00:29:18.025230Z",
"url": "https://files.pythonhosted.org/packages/51/d6/ae276667c7bf4b5e3acc8085c915aff03fe15ebd37bac18fef5675cdf5d2/pytest_parametrize-1.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-10 00:29:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MarcinSkrobczynski",
"github_project": "pytest-parametrize",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pytest-parametrize"
}