From 28cb15d1313c77a04d1b119089dd1b4c7ac5ebb1 Mon Sep 17 00:00:00 2001 From: Milan Rossa Date: Mon, 5 Aug 2019 15:12:27 +0200 Subject: [PATCH] tests/misc/sys_atexit: Add test for new sys.atexit feature. --- tests/misc/sys_atexit.py | 18 ++++++++++++++++++ tests/misc/sys_atexit.py.exp | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 tests/misc/sys_atexit.py create mode 100644 tests/misc/sys_atexit.py.exp 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