diff options
Diffstat (limited to 'tests/basics/struct_micropython.py')
| -rw-r--r-- | tests/basics/struct_micropython.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/basics/struct_micropython.py b/tests/basics/struct_micropython.py index e3b0ea508..4b9dfe137 100644 --- a/tests/basics/struct_micropython.py +++ b/tests/basics/struct_micropython.py @@ -6,9 +6,8 @@ except: try: import struct except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit class A(): pass @@ -18,3 +17,16 @@ o = A() s = struct.pack("<O", o) o2 = struct.unpack("<O", s) print(o is o2[0]) + +# pack and unpack pointer to a string +# This requires uctypes to get the address of the string and instead of +# putting this in a dedicated test that can be skipped we simply pass +# if the import fails. +try: + import uctypes + o = uctypes.addressof('abc') + s = struct.pack("<S", o) + o2 = struct.unpack("<S", s) + assert o2[0] == 'abc' +except ImportError: + pass |
