* Remove Cython * fix CI * fix coverage * fix tests * switching to pypyroject.toml * pre-commit all and use pre-commit for linting * no mypy tests on macos and windows on ci, use flake8-pyproject * fix docs and tests CI * check build is working * drop pytest-cov * window and macos ci with 3.11, reduce filtering * use pip-tools to pin all dependencies * fix docs and fastapi tests * fix test deps for 3.7 * no cache on tests job * revert fastapi changes, fix coverage * fix mypy coverage * test with older mypy * dotenv not required for mypy tests * split testing requirements std and extra * typo * @PrettyWood comments * correct branch name * mypy python_version and pr template
1.6 KiB
Hypothesis is the Python library for
property-based testing.
Hypothesis can infer how to construct type-annotated classes, and supports builtin types,
many standard library types, and generic types from the
typing and
typing_extensions modules by default.
From Pydantic v1.8 and Hypothesis v5.29.0,
Hypothesis will automatically load support for custom types like
PaymentCardNumber and PositiveFloat, so that the
st.builds()
and st.from_type()
strategies support them without any user configuration.
!!! warning Please note, while the plugin supports these types, hypothesis will(currently) generate values outside of given args for the constrained function types.
Example tests
{!.tmp_examples/hypothesis_property_based_test.md!}
Use with JSON Schemas
To test client-side code, you can use Model.schema() with the
hypothesis-jsonschema package
to generate arbitrary JSON instances matching the schema.
For web API testing, Schemathesis provides
a higher-level wrapper and can detect both errors and security vulnerabilities.