File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ this code, we add the default properties to each object *before* the
150
150
properties are validated, so the default values themselves will need to
151
151
be valid under the schema.)
152
152
153
- .. code-block :: python
153
+ .. testcode ::
154
154
155
155
from jsonschema import Draft7Validator, validators
156
156
@@ -205,7 +205,7 @@ defaults.
205
205
all of its properties, but only if your schema provides a default
206
206
value for the object itself, like so:
207
207
208
- .. code-block :: python
208
+ .. testcode ::
209
209
210
210
schema = {
211
211
"type": "object",
@@ -231,7 +231,7 @@ defaults.
231
231
it won't be instantiated at all, much less populated with default
232
232
properties.
233
233
234
- .. code-block :: python
234
+ .. testcode ::
235
235
236
236
del schema["properties"]["outer-object"]["default"]
237
237
obj2 = {}
Original file line number Diff line number Diff line change @@ -84,7 +84,9 @@ types as being acceptable for a validator object, then you should update an
84
84
existing `TypeChecker ` or create a new one. You may then create a new
85
85
`Validator ` via `jsonschema.validators.extend `.
86
86
87
- .. code-block :: python
87
+ .. testcode ::
88
+
89
+ from jsonschema import validators
88
90
89
91
class MyInteger(object):
90
92
pass
@@ -97,7 +99,10 @@ existing `TypeChecker` or create a new one. You may then create a new
97
99
98
100
type_checker = Draft3Validator.TYPE_CHECKER.redefine("number", is_my_int)
99
101
100
- CustomValidator = extend(Draft3Validator, type_checker = type_checker)
102
+ CustomValidator = validators.extend(
103
+ Draft3Validator,
104
+ type_checker=type_checker,
105
+ )
101
106
validator = CustomValidator(schema={"type" : "number"})
102
107
103
108
@@ -129,7 +134,7 @@ which each included validator class implements.
129
134
For example, if you wanted to validate a schema you created against the
130
135
Draft 7 meta-schema, you could use:
131
136
132
- .. code-block :: python
137
+ .. testcode ::
133
138
134
139
from jsonschema import Draft7Validator
135
140
You can’t perform that action at this time.
0 commit comments