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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_case-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 df4318fe25bfa3bfba6651c58b03f03c52166f443d2e8b505a2efb93c65759e9
MD5 ea1579b4b95b80ca523e89d95ac05fc5
BLAKE2b-256 4c79e4962f5b53ad1a9cce3ffb6d406c9a03f880f43285dedbe49896112ffc78

See more details on using hashes here.

Provenance

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

Publisher: release.yml on eitanwass/pytest-case

Attestations:

File details

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

File metadata

  • Download URL: pytest_case-0.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a99dbff58cf71bf316a818b4618cfced26625e463250918cd3f74bd852e001e
MD5 eed1276a018e27bd4e859ea93699889c
BLAKE2b-256 b1cff2bdc5640698ca3397988b9bc5b434fa362bca9d61c9838e04efa7ac78a0

See more details on using hashes here.

Provenance

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