Skip to content

Commit 0ecce77

Browse files
committed
tests/extmod/ujson_dump.py: Add test for dump to non-stream object.
1 parent a5f5552 commit 0ecce77

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/extmod/ujson_dump.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,15 @@
1616
s = StringIO()
1717
json.dump({"a": (2, [3, None])}, s)
1818
print(s.getvalue())
19+
20+
# dump to a small-int not allowed
21+
try:
22+
json.dump(123, 1)
23+
except (AttributeError, OSError): # CPython and uPy have different errors
24+
print('Exception')
25+
26+
# dump to an object not allowed
27+
try:
28+
json.dump(123, {})
29+
except (AttributeError, OSError): # CPython and uPy have different errors
30+
print('Exception')

0 commit comments

Comments
 (0)