Commit 268810da authored by Stefan Behnel's avatar Stefan Behnel

change test to avoid failures if the GC environment isn't clean before running it

parent e9597cd1
"""
Initial cleanup and 'calibration':
>>> _ = gc.collect()
>>> old_unreachable = gc.collect()
Test:
>>> x = SimpleGarbage()
SimpleGarbage(1) __cinit__
>>> del x
SimpleGarbage(1) __dealloc__
Collector.__dealloc__
collect 0
Make sure nothing changed in the environment:
>>> new_unreachable = get_new_unreachable()
>>> new_unreachable == old_unreachable or (old_unreachable, new_unreachable)
True
"""
import gc
cdef Py_ssize_t new_unreachable = 0
def get_new_unreachable():
return new_unreachable
cdef int counter = 0
cdef int next_counter():
global counter
......@@ -22,7 +35,8 @@ cdef class Collector:
# refcount is artificially inflated for the duration of that function.
def __dealloc__(self):
print "Collector.__dealloc__"
print "collect", gc.collect()
global new_unreachable
new_unreachable = gc.collect()
cdef class SimpleGarbage:
cdef Collector c # to participate in garbage collection
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment