[Python-checkins] python/nondist/sandbox/datetime test_both.py,1.46,1.47

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
2002年12月06日 18:12:34 -0800


Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv13915
Modified Files:
	test_both.py 
Log Message:
Added refcount-based leak detection as discussed on Python-Dev. Pass
option--leak under a debug build to trigger this (it will run the tests
in an infinite loop then, and print stuff after each run).
Index: test_both.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_both.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** test_both.py	6 Dec 2002 20:32:23 -0000	1.46
--- test_both.py	7 Dec 2002 02:12:31 -0000	1.47
***************
*** 5,8 ****
--- 5,11 ----
 Pass c on the cmdline to test the C implementation; else the Python
 implementation is tested.
+ 
+ Run with --leak under a debug build to get some simple but powerful leak
+ detection.
 """
 
***************
*** 1122,1128 ****
 
 def test_main():
 r = unittest.TextTestRunner(stream=sys.stdout, verbosity=2)
 s = test_suite()
! r.run(s)
 
 if __name__ == "__main__":
--- 1125,1150 ----
 
 def test_main():
+ import gc
+ import sys
+ 
 r = unittest.TextTestRunner(stream=sys.stdout, verbosity=2)
 s = test_suite()
! lastrc = None
! while True:
! r.run(s)
! gc.collect()
! if gc.garbage:
! raise SystemError("gc.garbage not empty after test run: %r" %
! gc.garbage)
! if hasattr(sys, 'gettotalrefcount'):
! thisrc = sys.gettotalrefcount()
! print '*' * 10, 'total refs:', thisrc,
! if lastrc:
! print 'delta:', thisrc - lastrc
! else:
! print
! lastrc = thisrc
! if '--leak' not in sys.argv:
! break
 
 if __name__ == "__main__":

AltStyle によって変換されたページ (->オリジナル) /