[pypy-commit] pypy fix-vmprof-stacklet-switch-2: add a pytest finalizer to check that we called {start, stop}_sampling an even amount of times. I have no idea how to write a test for it, though :(

antocuni pypy.commits at gmail.com
Tue Nov 28 10:10:49 EST 2017


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: fix-vmprof-stacklet-switch-2
Changeset: r93194:ff5fd2e1f430
Date: 2017-11-28 16:09 +0100
http://bitbucket.org/pypy/pypy/changeset/ff5fd2e1f430/

Log:	add a pytest finalizer to check that we called {start,stop}_sampling
	an even amount of times. I have no idea how to write a test for it,
	though :(

diff --git a/rpython/rlib/rvmprof/test/support.py b/rpython/rlib/rvmprof/test/support.py
--- a/rpython/rlib/rvmprof/test/support.py
+++ b/rpython/rlib/rvmprof/test/support.py
@@ -31,5 +31,12 @@
 def fakevmprof(request, monkeypatch):
     fake = FakeVMProf()
     monkeypatch.setattr(rvmprof.rvmprof, '_vmprof_instance', fake)
+    #
+    def check_status():
+        if fake._ignore_signals != 1:
+            msg = ('Invalid value for fakevmprof._ignore_signals: expected 1, '
+                   'got %d. This probably means that you called '
+                   '{start,stop}_sampling() a wrong number of times')
+            raise ValueError, msg % fake._ignore_signals
+    request.addfinalizer(check_status)
     return fake
-


More information about the pypy-commit mailing list