summaryrefslogtreecommitdiffstatshomepage
path: root/tests/misc
diff options
context:
space:
mode:
authorMilan Rossa <rossa.milan@gmail.com>2019-08-05 15:12:27 +0200
committerDamien George <damien.p.george@gmail.com>2019-08-15 17:31:04 +1000
commit28cb15d1313c77a04d1b119089dd1b4c7ac5ebb1 (patch)
tree1031bc8b3080871cdf28223eb623234cff0d7bdd /tests/misc
parent6f0c6bd77410ad25ade6a3999c62451ae76ea60a (diff)
downloadmicropython-28cb15d1313c77a04d1b119089dd1b4c7ac5ebb1.tar.gz
micropython-28cb15d1313c77a04d1b119089dd1b4c7ac5ebb1.zip
tests/misc/sys_atexit: Add test for new sys.atexit feature.
Diffstat (limited to 'tests/misc')
-rw-r--r--tests/misc/sys_atexit.py18
-rw-r--r--tests/misc/sys_atexit.py.exp2
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/misc/sys_atexit.py b/tests/misc/sys_atexit.py
new file mode 100644
index 0000000000..f5317953c2
--- /dev/null
+++ b/tests/misc/sys_atexit.py
@@ -0,0 +1,18 @@
+# test sys.atexit() function
+
+import sys
+try:
+ sys.atexit
+except AttributeError:
+ print('SKIP')
+ raise SystemExit
+
+some_var = None
+
+def do_at_exit():
+ print("done at exit:", some_var)
+
+sys.atexit(do_at_exit)
+
+some_var = "ok"
+print("done before exit")
diff --git a/tests/misc/sys_atexit.py.exp b/tests/misc/sys_atexit.py.exp
new file mode 100644
index 0000000000..3cbdae9a5a
--- /dev/null
+++ b/tests/misc/sys_atexit.py.exp
@@ -0,0 +1,2 @@
+done before exit
+done at exit: ok