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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_case-0.2.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.2.2.tar.gz
Algorithm Hash digest
SHA256 a8cd153f762beff9da2675fbac802fa4dbcd44a36b41100d740b814a52ec225b
MD5 3860bc4bbcd0b6236f1c0e3f247fa880
BLAKE2b-256 174703d067b47ef956ccd9a181b7769c12edc7466659d9f52c9614ec65c45337

See more details on using hashes here.

Provenance

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

Publisher: release.yml on eitanwass/pytest-case

Attestations:

File details

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

File metadata

  • Download URL: pytest_case-0.2.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.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 798e107d3ffafe3229e454b615f21a8a64210764bea8045ee996e69c4cff3970
MD5 96fb06ed14a048accd1081a377af61db
BLAKE2b-256 c5dcf605469bd06956e6bc4b07257b98263b332e3247b9d57ef4acc41b9ff55a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_case-0.2.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