summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormicroDev <70126934+microDev1@users.noreply.github.com>2021-01-12 18:28:38 +0530
committermicroDev <70126934+microDev1@users.noreply.github.com>2021-01-12 18:28:38 +0530
commitcd16f29efdc2df4544ffcccca5ae227be2f816ba (patch)
tree8a90c5519f5b478d72d1647f7a537918bb543fdd /tests
parent5f448139e0c5972def8a8f138cd29afd1e9222f8 (diff)
parent047708e36e67beee14771120296cdf758f00601d (diff)
Merge branch 'main' into TouchAlarm
Diffstat (limited to 'tests')
-rw-r--r--tests/extmod/umsgpack_pack.py30
-rw-r--r--tests/extmod/umsgpack_pack.py.ext5
2 files changed, 35 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')
diff --git a/tests/extmod/umsgpack_pack.py.ext b/tests/extmod/umsgpack_pack.py.ext
new file mode 100644
index 000000000..2f966be06
--- /dev/null
+++ b/tests/extmod/umsgpack_pack.py.ext
@@ -0,0 +1,5 @@
+b'\xc2'
+b'\x82\xa1a\x96\xff\x00\x02\x92\x03\xc0\xd1\x00\x80\xc4\x07abcdefg\xa1b\xd4\x05x'
+Exception ExtType
+Exception to int
+Exception to object