Install & Compatibility
Where this runs
tested against v0.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.036s · 30.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.9s · import 0.032s · 31MB
29MB installed
● package 29MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
schema
✓ from pytest_schema import schema
Direct import from pytest_schema
like_schema
✓ from pytest_schema import like_schema
Alias for like method
exact_schema
✓ from pytest_schema import exact_schema
Alias for exact method
Basic usage of schema, like_schema, and exact_schema in pytest tests.
from pytest_schema import schema
def test_validate_schema():
expected = {"name": str, "age": int}
actual = {"name": "Alice", "age": 30}
assert actual == schema(expected)
def test_like_schema():
from pytest_schema import like_schema
expected = {"id": int, "value": str}
actual = {"id": 1, "value": "foo", "extra": True}
assert actual == like_schema(expected)
def test_exact_schema():
from pytest_schema import exact_schema
expected = {"key": str}
actual = {"key": "val"}
assert actual == exact_schema(expected)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pytest_schema'
pytest-schema is not installed or installed in a different environment.
fixRun `pip install pytest-schema` in your virtual environment.
TypeError: 'Schema' object is not callable
Using the `schema` object from `schema` library directly instead of pytest_schema's wrapper.
fixImport `schema` from `pytest_schema` instead: `from pytest_schema import schema`.
AssertionError: assert <pytest_schema...> == ...
The schema comparison failed because the actual data does not match the schema.
fixCheck the types and structure of your actual data against the schema definition.
Upgrade
Version history
0.1.2latest on PyPI · released Feb 16, 2024
Audit
Dependencies
pytestrequiredCore testing framework
schemarequiredSchema validation library