[pypy-commit] pypy default: Skip these tests if we're running "py.test -A" with a PyPy compiled

arigo noreply at buildbot.pypy.org
Sat Jan 11 12:31:43 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r68597:57de6303e2f4
Date: 2014-01-11 12:30 +0100
http://bitbucket.org/pypy/pypy/changeset/57de6303e2f4/

Log:	Skip these tests if we're running "py.test -A" with a PyPy compiled
	without DO_TRACING.

diff --git a/pypy/module/_rawffi/test/test_tracker.py b/pypy/module/_rawffi/test/test_tracker.py
--- a/pypy/module/_rawffi/test/test_tracker.py
+++ b/pypy/module/_rawffi/test/test_tracker.py
@@ -1,9 +1,21 @@
+import py
+from pypy.conftest import option
 from pypy.module._rawffi.tracker import Tracker
 
+
 class AppTestTracker:
     spaceconfig = dict(usemodules=['_rawffi', 'struct'])
 
     def setup_class(cls):
+        #
+        # detect if we're running on PyPy with DO_TRACING not compiled in
+        if option.runappdirect:
+            try:
+                import _rawffi
+                _rawffi._num_of_allocated_objects()
+            except (ImportError, RuntimeError), e:
+                py.test.skip(str(e))
+        #
         Tracker.DO_TRACING = True
 
     def test_array(self):
diff --git a/pypy/module/_rawffi/tracker.py b/pypy/module/_rawffi/tracker.py
--- a/pypy/module/_rawffi/tracker.py
+++ b/pypy/module/_rawffi/tracker.py
@@ -2,6 +2,8 @@
 """ The file that keeps track about freed/kept-alive objects allocated
 by _rawffi. Used for debugging ctypes
 """
+from pypy.interpreter.error import OperationError
+
 
 class Tracker(object):
     DO_TRACING = False      # make sure this stays False by default!
@@ -20,6 +22,9 @@
 tracker = Tracker()
 
 def num_of_allocated_objects(space):
+    if not tracker.DO_TRACING:
+        raise OperationError(space.w_RuntimeError,
+                             space.wrap("DO_TRACING not enabled in this PyPy"))
     return space.wrap(len(tracker.alloced))
 
 def print_alloced_objects(space):


More information about the pypy-commit mailing list