pytest-case
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, -1, mark=pytest.mark.xfail)
@case(add_test_cases())
def test__divide(a: int, b: int, expected: int) -> None:
assert expected == a / b
Features
Default Arguments Values
@case("Check for Failure", val="Failure")
@case("Check for success", val="Success", sanity="Success")
def test__with_default(val: str, sanity: str = "Failure") -> None:
assert sanity == val
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
Using Fixtures
- Using pytest built-in
requestfixture.def test__with_request_fixture(request: Any) -> None: fixture_value = request.getfixturevalue("fixture_name") ...
- Using pytest-lazy-fixtures
from pytest_case import case from pytest_lazy_fixtures import lf @case("Lazy Fixture Case", lf("fixture_name")) def test__with_lf_cases(fixture_val: Any) -> None ...
Project Roadmap:
These are the the predicted checkpoints for this project:
- Test Arguments Default Values That would be cool!
- Test Marks Marks that are currently supported by pytest, such as: xfail, skip, ...
- Tests Cases Generators
Provide a generator function to the
caseto automatically generate cases. - Use Fixtures Use fixtures in cases and tests
- Tests Samples Generation Generate parameters to catch edge-cases, based on restrictions or datasets.
Metadata
Release files for pytest-case 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_case-1.0.0.tar.gz | 8.5 kB | With provenance | Details for pytest_case-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_case-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pytest_case-1.0.0-py3-none-any.whl |
Total release size: 18.8 kB
Release files / pytest_case-1.0.0.tar.gz
| Download URL | pytest_case-1.0.0.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12dfb557ad760ea517c429a20743d95d536a008a2a1c5e663e5dfcc25109bd8b
|
|
BLAKE2b-256 checksum How to use checksums |
c07005e97274ffe052b886a2accf77ad00b01628b27fd34cebb7514655e8268f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2024.
Transparency logRelease files / pytest_case-1.0.0-py3-none-any.whl
| Download URL | pytest_case-1.0.0-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c0f25e6920f1a2a1cdc0cdb1066265666b18f370dc5c5a96013cd3692bae9cd
|
|
BLAKE2b-256 checksum How to use checksums |
f0a2ec8a13283d23c32cef21eae8b494fadf436dce131df6166bbdd9087a86ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2024.
Transparency logSecurity for pytest-case 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pytest_case-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2024.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.