diff options
author | Julian Berman <Julian@GrayVines.com> | 2022-08-02 13:46:50 +0300 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2022-08-02 13:46:50 +0300 |
commit | 60bb7b49bf62c0e180e0f1072d034b1a021b9be7 (patch) | |
tree | 408cf49124e5cd37c32df47dc3b4b2ac813a78a5 /docs | |
parent | 6f18518ebc5855876aab846183c80372e454ac94 (diff) | |
download | jsonschema-60bb7b49bf62c0e180e0f1072d034b1a021b9be7.tar.gz |
(Re-)enable more doctests.
It is way too easy to silently pass these :( -- specifically,
the doctest directive only works for things with >>> prompts.
Diffstat (limited to 'docs')
-rw-r--r-- | docs/faq.rst | 6 | ||||
-rw-r--r-- | docs/validate.rst | 11 |
2 files changed, 11 insertions, 6 deletions
diff --git a/docs/faq.rst b/docs/faq.rst index bddb93a..3bbed31 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -150,7 +150,7 @@ this code, we add the default properties to each object *before* the properties are validated, so the default values themselves will need to be valid under the schema.) - .. code-block:: python + .. testcode:: from jsonschema import Draft7Validator, validators @@ -205,7 +205,7 @@ defaults. all of its properties, but only if your schema provides a default value for the object itself, like so: - .. code-block:: python + .. testcode:: schema = { "type": "object", @@ -231,7 +231,7 @@ defaults. it won't be instantiated at all, much less populated with default properties. - .. code-block:: python + .. testcode:: del schema["properties"]["outer-object"]["default"] obj2 = {} diff --git a/docs/validate.rst b/docs/validate.rst index abb52cb..f68f2f9 100644 --- a/docs/validate.rst +++ b/docs/validate.rst @@ -84,7 +84,9 @@ types as being acceptable for a validator object, then you should update an existing `TypeChecker` or create a new one. You may then create a new `Validator` via `jsonschema.validators.extend`. -.. code-block:: python +.. testcode:: + + from jsonschema import validators class MyInteger(object): pass @@ -97,7 +99,10 @@ existing `TypeChecker` or create a new one. You may then create a new type_checker = Draft3Validator.TYPE_CHECKER.redefine("number", is_my_int) - CustomValidator = extend(Draft3Validator, type_checker=type_checker) + CustomValidator = validators.extend( + Draft3Validator, + type_checker=type_checker, + ) validator = CustomValidator(schema={"type" : "number"}) @@ -129,7 +134,7 @@ which each included validator class implements. For example, if you wanted to validate a schema you created against the Draft 7 meta-schema, you could use: -.. code-block:: python +.. testcode:: from jsonschema import Draft7Validator |