diff options
Diffstat (limited to 'tests/extmod/json_dump.py')
| -rw-r--r-- | tests/extmod/json_dump.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/extmod/json_dump.py b/tests/extmod/json_dump.py new file mode 100644 index 000000000..897d33cc8 --- /dev/null +++ b/tests/extmod/json_dump.py @@ -0,0 +1,26 @@ +try: + from io import StringIO + import json +except ImportError: + print("SKIP") + raise SystemExit + +s = StringIO() +json.dump(False, s) +print(s.getvalue()) + +s = StringIO() +json.dump({"a": (2, [3, None])}, s) +print(s.getvalue()) + +# dump to a small-int not allowed +try: + json.dump(123, 1) +except (AttributeError, OSError): # CPython and uPy have different errors + print("Exception") + +# dump to an object not allowed +try: + json.dump(123, {}) +except (AttributeError, OSError): # CPython and uPy have different errors + print("Exception") |
