diff options
| author | Damien George <damien@micropython.org> | 2025-09-22 11:41:36 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-09-23 14:13:37 +1000 |
| commit | bf08f601fa67f005d5f21095b8fd455f7c7e7fab (patch) | |
| tree | d224c3168f9ef79a71a066770267711c75ef644e /tests/cmdline/cmd_module_atexit_exc.py | |
| parent | 8c389db6ea552a7a5bfcb2de644bc3e8849ef521 (diff) | |
tests/cmdline: Add tests for using -m combined with sys.atexit.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/cmdline/cmd_module_atexit_exc.py')
| -rw-r--r-- | tests/cmdline/cmd_module_atexit_exc.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/cmdline/cmd_module_atexit_exc.py b/tests/cmdline/cmd_module_atexit_exc.py new file mode 100644 index 000000000..88940a774 --- /dev/null +++ b/tests/cmdline/cmd_module_atexit_exc.py @@ -0,0 +1,19 @@ +# cmdline: -m cmdline.cmd_module_atexit_exc +# +# Test running as a module and using sys.atexit, with script completion via sys.exit. + +import sys + +if not hasattr(sys, "atexit"): + print("SKIP") + raise SystemExit + +# Verify we ran as a module. +print(sys.argv) + +sys.atexit(lambda: print("done")) + +print("start") + +# This will raise SystemExit to finish the script, and atexit should still be run. +sys.exit(0) |
