Files
micropython/tests/extmod/marshal_micropython.py
Damien George c3a18d74eb extmod/modmarshal: Add new marshal module.
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>
2025-02-11 16:54:20 +11:00

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()