Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r91949:a22659423f20
Date: 2017-07-21 14:49 +0200
http://bitbucket.org/pypy/pypy/changeset/a22659423f20/
Log: cleanup cleanup code
diff --git a/pypy/module/cpyext/test/test_api.py
b/pypy/module/cpyext/test/test_api.py
--- a/pypy/module/cpyext/test/test_api.py
+++ b/pypy/module/cpyext/test/test_api.py
@@ -64,14 +64,7 @@
except OperationError as e:
print e.errorstr(self.space)
raise
-
- try:
- self.space.getexecutioncontext().cleanup_cpyext_state()
- except AttributeError:
- pass
-
- if self.check_and_print_leaks():
- assert False, "Test leaks or loses object(s)."
+ self.cleanup()
@slot_function([PyObject], lltype.Void)
def PyPy_GetWrapped(space, w_arg):
diff --git a/pypy/module/cpyext/test/test_cpyext.py
b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -80,14 +80,13 @@
'micronumpy', 'mmap'
])
- @staticmethod
- def cleanup_references(space):
- return
+ def cleanup(self):
+ self.space.getexecutioncontext().cleanup_cpyext_state()
+ rawrefcount._collect()
+ self.space.user_del_action._run_finalizers()
+ leakfinder.stop_tracking_allocations(check=False)
+ assert not self.space.finalizer_queue.next_dead()
- def check_and_print_leaks(self):
- rawrefcount._collect()
- leakfinder.stop_tracking_allocations(check=False)
- return False
class AppTestApi(LeakCheckingTest):
def setup_class(cls):
@@ -104,15 +103,7 @@
def teardown_method(self, meth):
if self.runappdirect:
return
- self.space.getexecutioncontext().cleanup_cpyext_state()
- self.cleanup_references(self.space)
- # XXX: like AppTestCpythonExtensionBase.teardown_method:
- # find out how to disable check_and_print_leaks() if the
- # test failed
- assert not self.check_and_print_leaks(), (
- "Test leaks or loses object(s). You should also check if "
- "the test actually passed in the first place; if it failed "
- "it is likely to reach this place.")
+ self.cleanup()
@pytest.mark.skipif(only_pypy, reason='pypy only test')
def test_only_import(self):
@@ -280,7 +271,6 @@
self.space.call_method(self.space.sys.get("stdout"), "flush")
freeze_refcnts(self)
- #self.check_and_print_leaks()
def unimport_module(self, name):
"""
@@ -292,17 +282,12 @@
def teardown_method(self, func):
if self.runappdirect:
+ self.w_debug_collect()
return
+ debug_collect(self.space)
for name in self.imported_module_names:
self.unimport_module(name)
- self.space.getexecutioncontext().cleanup_cpyext_state()
- self.cleanup_references(self.space)
- # XXX: find out how to disable check_and_print_leaks() if the
- # test failed...
- assert not self.check_and_print_leaks(), (
- "Test leaks or loses object(s). You should also check if "
- "the test actually passed in the first place; if it failed "
- "it is likely to reach this place.")
+ self.cleanup()
class AppTestCpythonExtension(AppTestCpythonExtensionBase):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit