Skip to main content

A clean, modern, wrapper for pytest.mark.parametrize

Project description

pytest-case

workflow success codecov

PyPI - Downloads PyPI - Version

Usage examples:

import pytest
from typing import Tuple, Generator
from pytest_case import case


def add_test_cases() -> Generator[Tuple[int, int, int]]:
    yield (
        n
        for n in [
            (3, 3, 6),
            (3, 4, 7),
            (-1, 6, 5),
        ]
    )


@case("regular args", 4, 2, 2)
@case(
    "params as kwargs",
    a=2,
    b=2,
    expected=1,
)
@case('with expected fail', 1, 0, mark=pytest.mark.xfail)
@case(add_test_cases())
def test__divide(a, b, expected) -> None:
    assert expected == a / b

Features

Generator Case

from itertools import product
from pytest_case import case

@case(product(
    ("Chrome", "Firefox", "Safari"), 
    ("Windows", "macOS", "Linux")
))
def test__browser_os_compatibility(browser: str, operating_system: str) -> None:
    # Will generate cases:
    # ("Chrome", "Windows"), ("Chrome", "macOS"), ("Chrome", "Linux"), ("Firefox", "Windows"), ...
    pass

Project Roadmap:

These are the the predicted checkpoints for this project:

  • Test Marks Marks that are currently supported by pytest, such as: xfail, skip, ...
  • Tests Cases Generators Provide a generator function to the case to automatically generate cases.
  • Tests Samples Generation Generate parameters to catch edge-cases, based on restrictions or datasets.

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_case-0.1.2.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

pytest_case-0.1.2-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest_case-0.1.2.tar.gz.

File metadata

  • Download URL: pytest_case-0.1.2.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pytest_case-0.1.2.tar.gz
Algorithm Hash digest
SHA256 aaf72bb1666f59f3bd9c18c6c200006765f98e27cce20f013663a76459ef17fc
MD5 4ad594df292954bb20d430e73dc73ef0
BLAKE2b-256 1dbc5342369af270965999b41f8357ff6b539a2e4a79dec4b847d3d2f00c62b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_case-0.1.2.tar.gz:

Publisher: release.yml on eitanwass/pytest-case

Attestations:

File details

Details for the file pytest_case-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pytest_case-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pytest_case-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c6462f1e7e1bdcac1884855340ede1aa621a8f0961fab4ec75d64cb34eb15646
MD5 178b90a6500826ee92f3ec3705e921fd
BLAKE2b-256 6b76690b0b2d6a362143c1999c8bf22d04fff19b7cec2c3d571783b24331f506

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_case-0.1.2-py3-none-any.whl:

Publisher: release.yml on eitanwass/pytest-case

Attestations:

Supported by

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