Skip to content

Update README #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ The public API consists of just one function: `hypothesis_jsonschema.from_schema
which takes a JSON schema and returns a strategy for allowed JSON objects.

```python
import json
import re

import hypothesis.strategies as st

from hypothesis import given

from hypothesis_jsonschema import from_schema
Expand All @@ -25,9 +30,9 @@ def test_integers(value):
@given(
from_schema(
{"type": "string", "format": "card"},
# Standard formats work out of the box. Custom formats are ignored
# by default, but you can pass custom strategies for them - e.g.
custom_formats={"card": st.sampled_from(EXAMPLE_CARD_NUMBERS)},
custom_formats={
"card": st.sampled_from(EXAMPLE_CARD_NUMBERS)
},
)
)
def test_card_numbers(value):
Expand All @@ -41,7 +46,7 @@ def test_card_numbers(payload):
assert "\0" not in payload # use allow_x00=False to exclude null characters
# If you want to restrict generated strings characters which are valid in
# a specific character encoding, you can do that with the `codec=` argument.
payload.encode(codec="utf-8")
payload.encode(encoding="utf-8")
```

For more details on property-based testing and how to use or customise
Expand Down
Loading