pytest-cases
Separate test code from test cases in pytest.
Decision gist · record as of 2026-08-14
Yes. pytest-cases is actively maintained, has no known vulnerabilities, and solves a real problem in test organization. The low install friction and permissive license make it a straightforward addition to any pytest-based project. Install it if you have test suites with many cases or external test data that you want to keep separate from your test logic.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction with a pure-Python wheel distribution.
- Actively maintained as of March 2026 with recent commits.
- Depends on pytest and three utility packages (decopatch, makefun, packaging), all common in Python testing environments.
License · maintenance · safety
BSD 3-Clause (permissive) — BSD 3-Clause is permissive; you can use this package in commercial and proprietary projects with minimal restriction, provided you include the license text.
last release 2026-03-02 (165 days) · last repo commit 2026-03-02 · 376 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,020,857 downloads/mo, #4,491 on PyPI
Alternatives
Verify before relying
pip install pytest-cases
from pytest_cases import CaseData, parametrize_with_cases
@parametrize_with_cases
def test_example(case_data):
assert case_data is not None- Whether the package supports Python versions earlier than 3.9 (classifiers list 3.9 as minimum but requires_python is unspecified)
- How test case data is typically sourced (files, functions, external datasets) beyond the decorator API
What it is and what it does
pytest-cases is a pytest plugin that decouples test case definitions from test execution logic. Instead of embedding all test data inline or using pytest's built-in parametrize, you define cases separately (via decorators, fixtures, or data files) and reference them in test functions. The plugin handles the plumbing to inject each case into your test, reducing boilerplate and making test suites easier to maintain when you have many cases or shared test data.
It depends on pytest as its core framework, plus decopatch and makefun for decorator manipulation, and packaging for version handling. The package is actively maintained and classified as Production/Stable, with support for Python 3.9 through 3.14.
Use it for
- Organize large test suites where many test functions share the same logic but differ only in input data.
- Load test cases from external files or databases without hardcoding them into test functions.
- Reuse the same test case set across multiple test functions without duplication.
- Implement lazy-loaded test cases that are only instantiated when the test runs.
- Combine multiple case sources (fixtures, decorators, data files) in a single parametrized test.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
pytest-cases is actively maintained, has no known vulnerabilities, and solves a real problem in test organization. The low install friction and permissive license make it a straightforward addition to any pytest-based project. Install it if you have test suites with many cases or external test data that you want to keep separate from your test logic.
Install
pytest-cases on PyPI
Before you install
Low install friction with a pure-Python wheel distribution. Actively maintained as of March 2026 with recent commits. Depends on pytest and three utility packages (decopatch, makefun, packaging), all common in Python testing environments.
License in practice
BSD 3-Clause is permissive; you can use this package in commercial and proprietary projects with minimal restriction, provided you include the license text.
Quickstart
pip install pytest-cases
from pytest_cases import CaseData, parametrize_with_cases
@parametrize_with_cases
def test_example(case_data):
assert case_data is not None
Verify before relying
- Whether the package supports Python versions earlier than 3.9 (classifiers list 3.9 as minimum but requires_python is unspecified)
- How test case data is typically sourced (files, functions, external datasets) beyond the decorator API
Package facts
| License | BSD 3-Clause permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 4 packagesdecopatchmakefunpackagingpytest |
| Maintenance | Actively maintained 165 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,020,857 / month, #4,491 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Testing |
Evidence: pytest_cases-3.10.1-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “separate test data from code”
- pytest-casespytest-cases lets you separate test case data from test code in…
- ddtddt multiplies a single test case across multiple datasets, letting…
- testbooktestbook lets you write unit tests for Jupyter Notebooks in separate…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also parametrize · pytest-harvest · pytest-parametrization · pytest-lazy-fixtures · pytest-lazy-fixture · unittest-parametrize · pytest-describe · parameterized · pytest-print · pytest-datafiles