summaryrefslogtreecommitdiff
path: root/tests/extmod/umsgpack_pack.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/extmod/umsgpack_pack.py')
-rw-r--r--tests/extmod/umsgpack_pack.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/extmod/umsgpack_pack.py b/tests/extmod/umsgpack_pack.py
new file mode 100644
index 000000000..d9f0005e1
--- /dev/null
+++ b/tests/extmod/umsgpack_pack.py
@@ -0,0 +1,30 @@
+try:
+ from uio import BytesIO
+ import umsgpack as msgpack
+except:
+ try:
+ from io import BytesIO
+ import msgpack
+ except ImportError:
+ print("SKIP")
+ raise SystemExit
+
+b = BytesIO()
+msgpack.pack(False, s)
+print(b.getvalue())
+
+b = BytesIO()
+msgpack.pack({"a": (-1, 0, 2, [3, None], 128)}, b)
+print(b.getvalue())
+
+# pack to a small-int not allowed
+try:
+ msgpack.pack(123, 1)
+except (AttributeError, OSError): # CPython and uPy have different errors
+ print('Exception')
+
+# pack to an object not allowed
+try:
+ msgpack.pack(123, {})
+except (AttributeError, OSError): # CPython and uPy have different errors
+ print('Exception')