mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 21:11:12 +02:00
This commit implements a small subset of the CPython `marshal` module. It implements `marshal.dumps()` and `marshal.loads()`, but only supports (un)marshalling code objects at this stage. The semantics match CPython, except that the actual marshalled bytes is not compatible with CPython's marshalled bytes. The module is enabled at the everything level (only on the unix coverage build at this stage). Signed-off-by: Damien George <damien@micropython.org>
22 lines
516 B
Python
22 lines
516 B
Python
# Test the marshal module, MicroPython-specific functionality.
|
|
|
|
try:
|
|
import marshal
|
|
except ImportError:
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
import unittest
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
def test_function_with_children(self):
|
|
# Can't marshal a function with children (in this case the module has a child function f).
|
|
code = compile("def f(): pass", "", "exec")
|
|
with self.assertRaises(ValueError):
|
|
marshal.dumps(code)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|