Skip to content

Commit 19b3972

Browse files
author
Evgeniy Martynenko
committed
Update README
1 parent 72c50ad commit 19b3972

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ The public API consists of just one function: `hypothesis_jsonschema.from_schema
1111
which takes a JSON schema and returns a strategy for allowed JSON objects.
1212

1313
```python
14+
import json
15+
import re
16+
17+
import hypothesis.strategies as st
18+
1419
from hypothesis import given
1520

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

4752
For more details on property-based testing and how to use or customise

0 commit comments

Comments
 (0)