[pypy-svn] pypy default: Managed to write a failing test.

arigo commits-noreply at bitbucket.org
Wed Feb 9 19:44:36 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r41754:58c7ba7fb150
Date: 2011-02-09 19:28 +0100
http://bitbucket.org/pypy/pypy/changeset/58c7ba7fb150/

Log:	Managed to write a failing test.

diff --git a/pypy/interpreter/test/test_pyframe.py b/pypy/interpreter/test/test_pyframe.py
--- a/pypy/interpreter/test/test_pyframe.py
+++ b/pypy/interpreter/test/test_pyframe.py
@@ -1,6 +1,12 @@
+from pypy.tool import udir
+
 
 class AppTestPyFrame:
 
+    def setup_class(cls):
+        cls.w_udir = cls.space.wrap(str(udir.udir))
+        cls.w_tempfile1 = cls.space.wrap(str(udir.udir.join('tempfile1')))
+
     # test for the presence of the attributes, not functionality
 
     def test_f_locals(self):
@@ -202,6 +208,32 @@
         assert l[0][1] == 'call'
         assert res == 'hidden' # sanity
 
+    def test_trace_hidden_prints(self):
+        import sys
+
+        l = []
+        def trace(a,b,c):
+            l.append((a,b,c))
+            return trace
+
+        outputf = open(self.tempfile1, 'w')
+        def f():
+            print >> outputf, 1
+            print >> outputf, 2
+            print >> outputf, 3
+            return "that's the return value"
+
+        sys.settrace(trace)
+        f()
+        sys.settrace(None)
+        outputf.close()
+        # should get 1 "call", 3 "line" and 1 "return" events, and no call
+        # or return for the internal app-level implementation of 'print'
+        assert len(l) == 6
+        assert [what for (frame, what, arg) in l] == [
+            'call', 'line', 'line', 'line', 'line', 'return']
+        assert l[-1][2] == "that's the return value"
+
     def test_trace_return_exc(self):
         import sys
         l = []


More information about the Pypy-commit mailing list