Squashed commit of the following:

commit 0ac9337e69e5c98917e3dfcd2abca0d9e56051f4
Author: Juergen Edelbluth <jed@noreply.git.codebau.dev>
Date:   Tue Aug 16 18:42:52 2022 +0000

    Maintenance Update: Library update and POC tests

    - The POC tests help to make sure that the pytest feature used still works as expected
    - The lib update is for maintenance
This commit is contained in:
Jürgen Edelbluth 2022-08-16 18:45:15 +00:00
parent 9448b369c7
commit b2f4f8b245
Signed by: jed
GPG Key ID: 6DEAEDD5CDB646DF
5 changed files with 151 additions and 16 deletions

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.3"
version = "6.4.4"
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]
reports = ["lxml"]
python2 = ["typed-ast (>=1.4.0,<2)"]
dmypy = ["psutil (>=4.0)"]
python2 = ["typed-ast (>=1.4.0,<2)"]
reports = ["lxml"]
[[package]]
name = "mypy-extensions"
@ -304,12 +304,15 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "pygments"
version = "2.12.0"
version = "2.13.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"
@ -442,7 +445,7 @@ python-versions = ">=3.7"
pytest = ">=5.0"
[package.extras]
dev = ["pytest-asyncio", "tox", "pre-commit"]
dev = ["pre-commit", "tox", "pytest-asyncio"]
[[package]]
name = "pytest-mypy"
@ -464,6 +467,20 @@ 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"
@ -626,7 +643,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 = "cd95b8ffb0cffc324682ca1e38a133f6a8643a4f8145d0ac26a0411d1145b376"
content-hash = "e31c3fd874ec8dee26ad41df78f0ee2cb019d47af61879733499b1fff58745bd"
[metadata.files]
astroid = []
@ -656,7 +673,10 @@ 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 = []
isort = [
{file = "isort-5.10.1-py3-none-any.whl", hash = "sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7"},
{file = "isort-5.10.1.tar.gz", hash = "sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951"},
]
lazy-object-proxy = []
mccabe = []
mypy = []
@ -668,7 +688,10 @@ packaging = [
{file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
]
pathspec = []
pathspec = [
{file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"},
{file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"},
]
pbr = []
platformdirs = []
pluggy = [
@ -683,10 +706,7 @@ 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 = [
{file = "Pygments-2.12.0-py3-none-any.whl", hash = "sha256:dc9c10fb40944260f6ed4c688ece0cd2048414940f1cea51b8b226318411c519"},
{file = "Pygments-2.12.0.tar.gz", hash = "sha256:5eb116118f9612ff1ee89ac96437bb6b49e8f04d8a13b514ba26f620208e26eb"},
]
pygments = []
pylint = []
pyparsing = [
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
@ -697,7 +717,9 @@ pytest = [
{file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"},
]
pytest-bandit = []
pytest-black = []
pytest-black = [
{file = "pytest-black-0.3.12.tar.gz", hash = "sha256:1d339b004f764d6cd0f06e690f6dd748df3d62e6fe1a692d6a5500ac2c5b75a5"},
]
pytest-clarity = [
{file = "pytest-clarity-1.0.1.tar.gz", hash = "sha256:505fe345fad4fe11c6a4187fe683f2c7c52c077caa1e135f3e483fe112db7772"},
]
@ -708,7 +730,11 @@ pytest-cov = [
pytest-isort = []
pytest-mock = []
pytest-mypy = []
pytest-pylint = []
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"},
]
pyyaml = []
rich = []
six = [
@ -717,7 +743,10 @@ six = [
]
smmap = []
stevedore = []
toml = []
toml = [
{file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
]
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.1"
version = "0.2.2"
description = "Pytest plugin for Test Case Parametrization with CSV files"
authors = ["Juergen Edelbluth <csv_params@jued.de>"]
license = "MIT"
@ -140,6 +140,7 @@ 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"]

0
tests/poc/__init__.py Normal file
View File

44
tests/poc/conftest.py Normal file
View File

@ -0,0 +1,44 @@
"""
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

@ -0,0 +1,61 @@
"""
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