home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 April / PCWorld_2001-04_cd.bin / Software / TemaCD / webclean / !!!python!!! / BeOpen-Python-2.0.exe / TEST_ATEXIT.PY < prev    next >
Encoding:
Python Source  |  2000-09-28  |  598 b   |  25 lines

  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
  25.