Files
micropython/tests/cpydiff/modules_json_nonserializable.py
Jeff Epler 3844733d60 tests/cpydiff: Fix test case for modules_json_nonserializable.
The test case was producing the following error:

    Traceback (most recent call last):
      File "<stdin>", line 12, in <module>
    UnicodeError:

which did not demonstrate the intended difference (this particular
non-json-serializable object DID throw an exception! just not TypeError).

The updated test uses a byte string with all ASCII bytes inside, which
better illustrates the diference.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2024-11-11 12:35:03 +11:00

13 lines
272 B
Python

"""
categories: Modules,json
description: JSON module does not throw exception when object is not serialisable
cause: Unknown
workaround: Unknown
"""
import json
try:
print(json.dumps(b"shouldn't be able to serialise bytes"))
except TypeError:
print("TypeError")