Fred Drake | c19425d | 2000-06-28 15:07:31 +0000 | [diff] [blame] | 1 | # Test the exit module |
| 2 | from test_support import verbose |
| 3 | import atexit |
| 4 | |
| 5 | def handler1(): |
| 6 | print "handler1" |
| 7 | |
| 8 | def handler2(*args, **kargs): |
| 9 | print "handler2", args, kargs |
| 10 | |
| 11 | # save any exit functions that may have been registered as part of the |
| 12 | # test framework |
| 13 | _exithandlers = atexit._exithandlers |
| 14 | atexit._exithandlers = [] |
| 15 | |
| 16 | atexit.register(handler1) |
| 17 | atexit.register(handler2) |
| 18 | atexit.register(handler2, 7, kw="abc") |
| 19 | |
| 20 | # simulate exit behavior by calling atexit._run_exitfuncs directly... |
| 21 | atexit._run_exitfuncs() |
| 22 | |
| 23 | # restore exit handlers |
| 24 | atexit._exithandlers = _exithandlers |