Compare commits

..

No commits in common. "v0.2.2" and "v0.2.0" have entirely different histories.

6 changed files with 18 additions and 155 deletions

View File

@ -1,6 +1,6 @@
# pytest-csv-params
A pytest plugin to parametrize data-driven tests by CSV files.
A pytest plugin to parametrize tests by CSV files.
[![PyPI - Downloads](https://img.shields.io/pypi/dw/pytest-csv-params?label=PyPI%20downloads&style=for-the-badge)](https://pypi.org/project/pytest-csv-params/)
[![PyPI - Version](https://img.shields.io/pypi/v/pytest-csv-params?label=PyPI%20version&style=for-the-badge)](https://pypi.org/project/pytest-csv-params/)
@ -12,7 +12,7 @@ A pytest plugin to parametrize data-driven tests by CSV files.
- Python 3.8, 3.9 or 3.10
- pytest >= 7.1
There's no operating system dependent code in this plugin, so it should run anywhere where pytest runs.
There's no operating system dependend code in this plugin, so it should run anywhere where pytest runs.
## Installation
@ -92,8 +92,6 @@ The default CSV format is:
- If you need a `"` in the value, use `""` (double quote)
- Fields are separated by comma (`,`)
**The first line must contain the row names. Row names must match the parameters of the test method (except for an ID column that is configured as such -- see `id_col` decorator parameter).**
#### Example CSV
```text

59
poetry.lock generated
View File

@ -106,7 +106,7 @@ test = ["flake8 (==3.7.8)", "hypothesis (==3.55.3)"]
[[package]]
name = "coverage"
version = "6.4.4"
version = "6.4.3"
description = "Code coverage measurement for Python"
category = "dev"
optional = false
@ -223,9 +223,9 @@ tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
typing-extensions = ">=3.10"
[package.extras]
dmypy = ["psutil (>=4.0)"]
python2 = ["typed-ast (>=1.4.0,<2)"]
reports = ["lxml"]
python2 = ["typed-ast (>=1.4.0,<2)"]
dmypy = ["psutil (>=4.0)"]
[[package]]
name = "mypy-extensions"
@ -304,15 +304,12 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "pygments"
version = "2.13.0"
version = "2.12.0"
description = "Pygments is a syntax highlighting package written in Python."
category = "dev"
optional = false
python-versions = ">=3.6"
[package.extras]
plugins = ["importlib-metadata"]
[[package]]
name = "pylint"
version = "2.14.5"
@ -445,7 +442,7 @@ python-versions = ">=3.7"
pytest = ">=5.0"
[package.extras]
dev = ["pre-commit", "tox", "pytest-asyncio"]
dev = ["pytest-asyncio", "tox", "pre-commit"]
[[package]]
name = "pytest-mypy"
@ -467,20 +464,6 @@ pytest = [
{version = ">=6.2", markers = "python_version >= \"3.10\""},
]
[[package]]
name = "pytest-order"
version = "1.0.1"
description = "pytest plugin to run your tests in a specific order"
category = "dev"
optional = false
python-versions = ">=3.6"
[package.dependencies]
pytest = [
{version = ">=6.2.4", markers = "python_version >= \"3.10\""},
{version = ">=5.0", markers = "python_version < \"3.10\""},
]
[[package]]
name = "pytest-pylint"
version = "0.18.0"
@ -643,7 +626,7 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
[metadata]
lock-version = "1.1"
python-versions = "^3.8"
content-hash = "e31c3fd874ec8dee26ad41df78f0ee2cb019d47af61879733499b1fff58745bd"
content-hash = "cd95b8ffb0cffc324682ca1e38a133f6a8643a4f8145d0ac26a0411d1145b376"
[metadata.files]
astroid = []
@ -673,10 +656,7 @@ iniconfig = [
{file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
{file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
]
isort = [
{file = "isort-5.10.1-py3-none-any.whl", hash = "sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7"},
{file = "isort-5.10.1.tar.gz", hash = "sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951"},
]
isort = []
lazy-object-proxy = []
mccabe = []
mypy = []
@ -688,10 +668,7 @@ packaging = [
{file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
]
pathspec = [
{file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"},
{file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"},
]
pathspec = []
pbr = []
platformdirs = []
pluggy = [
@ -706,7 +683,10 @@ py = [
{file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"},
{file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"},
]
pygments = []
pygments = [
{file = "Pygments-2.12.0-py3-none-any.whl", hash = "sha256:dc9c10fb40944260f6ed4c688ece0cd2048414940f1cea51b8b226318411c519"},
{file = "Pygments-2.12.0.tar.gz", hash = "sha256:5eb116118f9612ff1ee89ac96437bb6b49e8f04d8a13b514ba26f620208e26eb"},
]
pylint = []
pyparsing = [
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
@ -717,9 +697,7 @@ pytest = [
{file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"},
]
pytest-bandit = []
pytest-black = [
{file = "pytest-black-0.3.12.tar.gz", hash = "sha256:1d339b004f764d6cd0f06e690f6dd748df3d62e6fe1a692d6a5500ac2c5b75a5"},
]
pytest-black = []
pytest-clarity = [
{file = "pytest-clarity-1.0.1.tar.gz", hash = "sha256:505fe345fad4fe11c6a4187fe683f2c7c52c077caa1e135f3e483fe112db7772"},
]
@ -730,11 +708,7 @@ pytest-cov = [
pytest-isort = []
pytest-mock = []
pytest-mypy = []
pytest-order = []
pytest-pylint = [
{file = "pytest-pylint-0.18.0.tar.gz", hash = "sha256:790c7a8019fab08e59bd3812db1657a01995a975af8b1c6ce95b9aa39d61da27"},
{file = "pytest_pylint-0.18.0-py3-none-any.whl", hash = "sha256:b63aaf8b80ff33c8ceaa7f68323ed04102c7790093ccf6bdb261a4c2dc6fd564"},
]
pytest-pylint = []
pyyaml = []
rich = []
six = [
@ -743,10 +717,7 @@ six = [
]
smmap = []
stevedore = []
toml = [
{file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
]
toml = []
tomli = [
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "pytest-csv-params"
version = "0.2.2"
version = "0.2.0"
description = "Pytest plugin for Test Case Parametrization with CSV files"
authors = ["Juergen Edelbluth <csv_params@jued.de>"]
license = "MIT"
@ -140,7 +140,6 @@ pytest-mock = "^3.8.2"
pytest-clarity = "^1.0.1"
pytest-bandit = "^0.6.1"
pytest-mypy = "^0.9.1"
pytest-order = "^1.0.1"
[build-system]
requires = ["poetry-core>=1.0.0"]

View File

View File

@ -1,44 +0,0 @@
"""
Configuration for the POC tests
"""
from typing import Dict, Type
import pytest
class CheapCounter:
"""
A simple counter
"""
counter: Dict[str, int] = {}
@classmethod
def get_value(cls, counter: str) -> int:
"""
Get the value of the counter
"""
current_value = cls.counter.get(counter, None)
if current_value is None:
cls.counter[counter] = 0
return 0
return current_value
@classmethod
def increment(cls, counter: str) -> None:
"""
Increment the value of the counter
"""
cls.counter[counter] = cls.get_value(counter) + 1
@pytest.fixture(scope="session")
def cheap_counter() -> Type[CheapCounter]:
"""
Deliver a simple counter as fixture
"""
return CheapCounter

View File

@ -1,61 +0,0 @@
"""
We are using a pytest feature heavily: Parametrization. These tests make sure this feature works still as expected.
"""
from string import ascii_letters
from typing import Generator, List, Type
import pytest
from .conftest import CheapCounter
def data_generator() -> Generator[List[str], None, None]:
"""
Simple Test Data Generator
"""
for val_a in ascii_letters[0:5]:
for val_b in ascii_letters[5:10]:
yield [val_a, val_b, f"{val_a}-{val_b}"]
@pytest.mark.order(1)
@pytest.mark.parametrize(
["val_a", "val_b", "val_c"],
[
["a", "b", "a:b"],
["c", "d", "c:d"],
],
)
def test_simple_parametrize(val_a: str, val_b: str, val_c: str, cheap_counter: Type[CheapCounter]) -> None:
"""
Test the standard parametrization
"""
assert f"{val_a}:{val_b}" == val_c
cheap_counter.increment("simple")
@pytest.mark.order(2)
@pytest.mark.parametrize(
["val_a", "val_b", "val_c"],
data_generator(),
)
def test_generator_parametrize(val_a: str, val_b: str, val_c: str, cheap_counter: Type[CheapCounter]) -> None:
"""
Test the generator way
"""
assert f"{val_a}-{val_b}" == val_c
cheap_counter.increment("generator")
@pytest.mark.order(3)
def test_evaluation(cheap_counter: Type[CheapCounter]) -> None:
"""
Evaluate the tests before
"""
assert cheap_counter.get_value("simple") == 2
assert cheap_counter.get_value("generator") == 25