[ctypes-commit] ctypes/unittests test_leaks.py,1.4,1.5
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2004-10-20 11:08:54
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24856 Modified Files: test_leaks.py Log Message: Adapt to current code. Index: test_leaks.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_leaks.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_leaks.py 18 Oct 2004 07:25:44 -0000 1.4 --- test_leaks.py 20 Oct 2004 11:08:45 -0000 1.5 *************** *** 50,58 **** def make_cyclic_structures(self, repeat): for i in xrange(repeat): class LIST(Structure): ! pass ! LIST._fields_ = [("pnext", POINTER(LIST))] del _pointer_type_cache[LIST] # XXX should this be a weakkeydict? - del LIST if hasattr(sys, "gettotalrefcount"): --- 50,58 ---- def make_cyclic_structures(self, repeat): for i in xrange(repeat): + PLIST = POINTER("LIST") class LIST(Structure): ! _fields_ = [("pnext", PLIST)] ! SetPointerType(PLIST, LIST) del _pointer_type_cache[LIST] # XXX should this be a weakkeydict? if hasattr(sys, "gettotalrefcount"): *************** *** 70,87 **** self.fail("leaking refcounts") ! def test_cycles_objcount(self): ! # not correct - gc.get_objects() returns only thos objects ! # that the garbage collector tracks. Correct would be to use ! # sys.getobjects(), but this is only available in debug build. ! last_objcount = 0 ! for x in xrange(5): ! self.make_cyclic_structures(1000) ! while gc.collect(): ! pass ! total_objcount = len(gc.get_objects()) ! if last_objcount >= total_objcount: ! return ! last_objcount = total_objcount ! self.fail("leaking objects") if __name__ == "__main__": --- 70,89 ---- self.fail("leaking refcounts") ! else: ! ! def test_cycles_objcount(self): ! # not correct - gc.get_objects() returns only thos objects ! # that the garbage collector tracks. Correct would be to use ! # sys.getobjects(), but this is only available in debug build. ! last_objcount = 0 ! for x in xrange(5): ! self.make_cyclic_structures(1000) ! while gc.collect(): ! pass ! total_objcount = len(gc.get_objects()) ! if last_objcount >= total_objcount: ! return ! last_objcount = total_objcount ! self.fail("leaking objects") if __name__ == "__main__": |