diff options
Diffstat (limited to 'lang/python/python-jsonschema/test.sh')
| -rw-r--r-- | lang/python/python-jsonschema/test.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lang/python/python-jsonschema/test.sh b/lang/python/python-jsonschema/test.sh new file mode 100644 index 000000000..37fe4925a --- /dev/null +++ b/lang/python/python-jsonschema/test.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +[ "$1" = python3-jsonschema ] || exit 0 + +python3 - << 'EOF' + +from jsonschema import validate + +# A sample schema, like what we'd get from json.load() +schema = { + "type" : "object", + "properties" : { + "price" : {"type" : "number"}, + "name" : {"type" : "string"}, + }, +} + +# If no exception is raised by validate(), the instance is valid. +validate(instance={"name" : "Eggs", "price" : 34.99}, schema=schema) + +EOF |
