pytest-schema
👍 Validate return values against a schema-like object in testing
Decision gist · record as of 2026-08-14
Yes, if you need lightweight schema validation in pytest tests and don't require active maintenance. The package is stable and low-friction to install, but its dormant status (910 days since last release) means it won't receive updates for new pytest or Python versions. Use it for straightforward response validation; consider alternatives if you need ongoing support or complex JSON Schema features.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction install with only two runtime dependencies (pytest and schema).
- Dormant maintenance status—last release was 910 days ago with no recent commits, though the repository is not archived and the package is marked Production/Stable.
License · maintenance · safety
MIT (permissive) — MIT license permits use in proprietary and open-source projects with minimal restriction; you must include a copy of the license and copyright notice.
last release 2024-02-16 (910 days) · last repo commit 2024-02-16 · 9 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 113,396 downloads/mo, #12,342 on PyPI
Alternatives
Verify before relying
pip install pytest-schema
from pytest_schema import schema
article_schema = {"id": int, "title": str, "completed": bool}
def test_endpoint(test_client):
response = test_client.get("/api/article/1")
assert schema(article_schema) == response- Whether the schema library's validation rules and error messages are sufficient for your test reporting needs.
- Current compatibility with modern pytest versions and whether dormant status affects future pytest updates.
What it is and what it does
pytest-schema is a pytest plugin that wraps the schema library to validate Python data structures—typically API responses, config objects, or parsed JSON—against declarative schema definitions in test assertions. It provides functions like schema(), exact_schema(), and like_schema() that compare actual data against a template defining expected types, nested structures, optional fields, and custom validation rules (regex, enums, lambdas). When data matches the schema, the assertion passes; when it doesn't, a SchemaError is raised with details about the mismatch.
The package is designed for testing REST endpoints, webhooks, or any code that returns structured data. You define a schema once—a plain Python dict with types and validators—then reuse it across multiple tests. It handles optional fields, nested objects, lists, and custom predicates, making it useful for regression testing API contracts or validating config file parsing without writing repetitive type checks.
Use it for
- Validate JSON responses from REST API endpoints match expected structure and types in integration tests.
- Test that config file parsing produces the correct nested dict/list structure with proper type conversions.
- Ensure backwards compatibility by checking that new API versions still satisfy older schema constraints.
- Validate webhook payloads or event data conform to a contract before processing in business logic.
- Check that data transformations (e.g., ORM queries, ETL pipelines) produce correctly typed and shaped output.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need lightweight schema validation in pytest tests and don't require active maintenance.
The package is stable and low-friction to install, but its dormant status (910 days since last release) means it won't receive updates for new pytest or Python versions. Use it for straightforward response validation; consider alternatives if you need ongoing support or complex JSON Schema features.
Install
pytest-schema on PyPI
Before you install
Low friction install with only two runtime dependencies (pytest and schema). Dormant maintenance status—last release was 910 days ago with no recent commits, though the repository is not archived and the package is marked Production/Stable.
License in practice
MIT license permits use in proprietary and open-source projects with minimal restriction; you must include a copy of the license and copyright notice.
Quickstart
pip install pytest-schema
from pytest_schema import schema
article_schema = {"id": int, "title": str, "completed": bool}
def test_endpoint(test_client):
response = test_client.get("/api/article/1")
assert schema(article_schema) == response
Verify before relying
- Whether the schema library's validation rules and error messages are sufficient for your test reporting needs.
- Current compatibility with modern pytest versions and whether dormant status affects future pytest updates.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagespytestschema |
| Maintenance | Dormant 910 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 113,396 / month, #12,342 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 :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Testing |
Evidence: pytest_schema-0.1.2-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 › “pytest response validation”
- pytest-schemaValidates function return values and API responses against schema…
- tavernTavern is a pytest plugin and command-line tool for automated testing…
- pytest-checkA pytest plugin that allows tests to continue running and collect…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also schema · pytest-responses · yamale · pandas-schema · pytest-unordered · django-pydantic-field · fastjsonschema · check-jsonschema · magicattr · json-schema-to-pydantic