Generate test data from JSON schemata with Hypothesis
Project description
hypothesis-jsonschema
A Hypothesis strategy for generating data that matches some JSON schema. It is currently in early alpha, but you can use it if you want. Here's the PyPI page.
The public API consists of a just two functions:
hypothesis_jsonschema.from_schema
Takes a JSON schema and return a strategy for allowed JSON objects.
This strategy supports almost all of the schema elements described in the draft RFC as of November 2018 (draft 7), with the following exceptions:
- For objects, the "dependencies" keyword is not supported.
- Subschemata are not supported, i.e. the "if", "then", and "else" keywords, and the "allOf, "anyOf", "oneOf", and "not" keywords.
- Schema reuse with "definitions" is not supported.
- string-encoding of non-JSON data is not supported.
- schema annotations, i.e. "title", "description", "default", "readOnly", "writeOnly", and "examples" are not supported.
- JSON pointers are not supported.
hypothesis_jsonschema.json_schemata
A Hypothesis strategy for arbitrary JSON schemata.
This strategy may generate anything that can be handled by from_schema
,
and is used to provide full branch coverage when testing this package.
Supported versions
hypothesis-jsonschema
does not support Python 2, because
it's close to end of life and Python 3.6+ is a
much nicer language. Contact me if you would like this changed and are
willing to either pay for or do the work to support Python 2.
In general, 0.x versions will require very recent versions of all dependencies because I don't want to deal with compatibility workarounds.
hypothesis-jsonschema
may make backwards-incompatible changes at any time
before version 1.x - that's what semver means! - but I've kept the API surface
small enough that this should be avoidable. The main source of breaks will be
if or when schema that never really worked turn into explicit errors instead
of generating values that don't quite match.
Changelog:
0.4.2 - 2019-02-14
- Dropped dependency on
canonicaljson
- Less warnings on Python 3.7
0.4.1 - 2019-02-06
- Relicensed under the more permissive Mozilla Public License, like Hypothesis
- Requires Hypothesis version 4.0 or later
- Fixed an array bounds bug with
maxItems
andcontains
keywords
0.4.0 - 2018-11-25
Supports string formats (email, datetime, etc) and simple use of the
"contains"
keyword for arrays.
0.3.0 - 2018-11-25
Good support for all basic types. MVP.
0.2.0 - 2018-11-24
Inference for null, boolean, string, and numeric types.
0.1.0 - 2018-11-21
Stake in the ground (generate arbitrary JSON and filter it!)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file hypothesis-jsonschema-0.4.2.tar.gz
.
File metadata
- Download URL: hypothesis-jsonschema-0.4.2.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af4f300bb5621e552f20f03a85299ac01ed652d4904e86a337fc7c10892dbf07 |
|
MD5 | 4be93aaac5eadf9a434ab7dd1c933948 |
|
BLAKE2b-256 | 48400936ae99e7b6a1498da7a605698f8a8f47324bec3702b573a0f3c371a1ba |