Skip to content

Commit 60bb7b4

Browse files
committed
(Re-)enable more doctests.
It is way too easy to silently pass these :( -- specifically, the doctest directive only works for things with >>> prompts.
1 parent 6f18518 commit 60bb7b4

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

docs/faq.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ this code, we add the default properties to each object *before* the
150150
properties are validated, so the default values themselves will need to
151151
be valid under the schema.)
152152

153-
.. code-block:: python
153+
.. testcode::
154154

155155
from jsonschema import Draft7Validator, validators
156156

@@ -205,7 +205,7 @@ defaults.
205205
all of its properties, but only if your schema provides a default
206206
value for the object itself, like so:
207207

208-
.. code-block:: python
208+
.. testcode::
209209

210210
schema = {
211211
"type": "object",
@@ -231,7 +231,7 @@ defaults.
231231
it won't be instantiated at all, much less populated with default
232232
properties.
233233

234-
.. code-block:: python
234+
.. testcode::
235235

236236
del schema["properties"]["outer-object"]["default"]
237237
obj2 = {}

docs/validate.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ types as being acceptable for a validator object, then you should update an
8484
existing `TypeChecker` or create a new one. You may then create a new
8585
`Validator` via `jsonschema.validators.extend`.
8686

87-
.. code-block:: python
87+
.. testcode::
88+
89+
from jsonschema import validators
8890

8991
class MyInteger(object):
9092
pass
@@ -97,7 +99,10 @@ existing `TypeChecker` or create a new one. You may then create a new
9799

98100
type_checker = Draft3Validator.TYPE_CHECKER.redefine("number", is_my_int)
99101

100-
CustomValidator = extend(Draft3Validator, type_checker=type_checker)
102+
CustomValidator = validators.extend(
103+
Draft3Validator,
104+
type_checker=type_checker,
105+
)
101106
validator = CustomValidator(schema={"type" : "number"})
102107

103108

@@ -129,7 +134,7 @@ which each included validator class implements.
129134
For example, if you wanted to validate a schema you created against the
130135
Draft 7 meta-schema, you could use:
131136

132-
.. code-block:: python
137+
.. testcode::
133138

134139
from jsonschema import Draft7Validator
135140

0 commit comments

Comments
 (0)