File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,11 @@ The public API consists of just one function: `hypothesis_jsonschema.from_schema
11
11
which takes a JSON schema and returns a strategy for allowed JSON objects.
12
12
13
13
``` python
14
+ import json
15
+ import re
16
+
17
+ import hypothesis.strategies as st
18
+
14
19
from hypothesis import given
15
20
16
21
from hypothesis_jsonschema import from_schema
@@ -25,9 +30,9 @@ def test_integers(value):
25
30
@given (
26
31
from_schema(
27
32
{" 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
+ },
31
36
)
32
37
)
33
38
def test_card_numbers (value ):
@@ -41,7 +46,7 @@ def test_card_numbers(payload):
41
46
assert " \0 " not in payload # use allow_x00=False to exclude null characters
42
47
# If you want to restrict generated strings characters which are valid in
43
48
# a specific character encoding, you can do that with the `codec=` argument.
44
- payload.encode(codec = " utf-8" )
49
+ payload.encode(encoding = " utf-8" )
45
50
```
46
51
47
52
For more details on property-based testing and how to use or customise
You can’t perform that action at this time.
0 commit comments