Author: Alexander Hesse <[email protected]>
Branch: split-rpython
Changeset: r60117:05d23aa0cf1c
Date: 2013-01-17 03:52 +0100
http://bitbucket.org/pypy/pypy/changeset/05d23aa0cf1c/

Log:    Moved LeakFinder from pypy.tool.pytest.plugins to rpython.conftest

diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -25,12 +25,6 @@
 def pytest_report_header():
     return "pytest-%s from %s" %(pytest.__version__, pytest.__file__)
 
-
-def pytest_addhooks(pluginmanager):
-    from pypy.tool.pytest.plugins import LeakFinder
-    pluginmanager.register(LeakFinder())
-
-
 def pytest_configure(config):
     global option
     option = config.option
diff --git a/pypy/tool/pytest/plugins.py b/pypy/tool/pytest/plugins.py
deleted file mode 100644
--- a/pypy/tool/pytest/plugins.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# pytest hooks, installed by pypy.conftest.
-
-import py
-from rpython.tool import leakfinder
-
-class LeakFinder:
-    """Track memory allocations during test execution.
-    
-    So far, only used by the function lltype.malloc(flavor='raw').
-    """
-    def pytest_runtest_setup(self, __multicall__, item):
-        __multicall__.execute()
-        if not isinstance(item, py.test.collect.Function):
-            return
-        if not getattr(item.obj, 'dont_track_allocations', False):
-            leakfinder.start_tracking_allocations()
-
-    def pytest_runtest_call(self, __multicall__, item):
-        __multicall__.execute()
-        if not isinstance(item, py.test.collect.Function):
-            return
-        item._success = True
-
-    def pytest_runtest_teardown(self, __multicall__, item):
-        __multicall__.execute()
-        if not isinstance(item, py.test.collect.Function):
-            return
-        if (not getattr(item.obj, 'dont_track_allocations', False)
-            and leakfinder.TRACK_ALLOCATIONS):
-            item._pypytest_leaks = leakfinder.stop_tracking_allocations(False)
-        else:            # stop_tracking_allocations() already called
-            item._pypytest_leaks = None
-
-        # check for leaks, but only if the test passed so far
-        if getattr(item, '_success', False) and item._pypytest_leaks:
-            raise leakfinder.MallocMismatch(item._pypytest_leaks)
diff --git a/rpython/conftest.py b/rpython/conftest.py
--- a/rpython/conftest.py
+++ b/rpython/conftest.py
@@ -40,3 +40,38 @@
     group.addoption('--viewloops', action="store_true",
            default=False, dest="viewloops",
            help="show only the compiled loops")
+
+def pytest_addhooks(pluginmanager):
+    pluginmanager.register(LeakFinder())
+
+class LeakFinder:
+    """Track memory allocations during test execution.
+    
+    So far, only used by the function lltype.malloc(flavor='raw').
+    """
+    def pytest_runtest_setup(self, __multicall__, item):
+        __multicall__.execute()
+        if not isinstance(item, py.test.collect.Function):
+            return
+        if not getattr(item.obj, 'dont_track_allocations', False):
+            leakfinder.start_tracking_allocations()
+
+    def pytest_runtest_call(self, __multicall__, item):
+        __multicall__.execute()
+        if not isinstance(item, py.test.collect.Function):
+            return
+        item._success = True
+
+    def pytest_runtest_teardown(self, __multicall__, item):
+        __multicall__.execute()
+        if not isinstance(item, py.test.collect.Function):
+            return
+        if (not getattr(item.obj, 'dont_track_allocations', False)
+            and leakfinder.TRACK_ALLOCATIONS):
+            item._pypytest_leaks = leakfinder.stop_tracking_allocations(False)
+        else:            # stop_tracking_allocations() already called
+            item._pypytest_leaks = None
+
+        # check for leaks, but only if the test passed so far
+        if getattr(item, '_success', False) and item._pypytest_leaks:
+            raise leakfinder.MallocMismatch(item._pypytest_leaks)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to