[pypy-commit] pypy default: A test for bc27ffd19a3c

arigo noreply at buildbot.pypy.org
Sun Mar 2 10:25:46 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r69606:931f9189e510
Date: 2014-03-02 10:25 +0100
http://bitbucket.org/pypy/pypy/changeset/931f9189e510/

Log:	A test for bc27ffd19a3c

diff --git a/pypy/interpreter/test/test_zpy.py b/pypy/interpreter/test/test_zpy.py
--- a/pypy/interpreter/test/test_zpy.py
+++ b/pypy/interpreter/test/test_zpy.py
@@ -7,10 +7,13 @@
 
 pypypath = py.path.local(pypy.__file__).dirpath("bin", "pyinteractive.py")
 
-def run(*args):
+def run(*args, **kwds):
+    stdin = kwds.pop('stdin', '')
+    assert not kwds
     argslist = map(str, args)
-    popen = subprocess.Popen(argslist, stdout=subprocess.PIPE)
-    stdout, stderr = popen.communicate()
+    popen = subprocess.Popen(argslist, stdin=subprocess.PIPE,
+                                       stdout=subprocess.PIPE)
+    stdout, stderr = popen.communicate(stdin)
     return stdout
 
 
@@ -99,3 +102,19 @@
                              stderr=subprocess.PIPE)
     _, stderr = popen.communicate()
     assert stderr.endswith('KeyError: <normalized>\n')
+
+
+def test_pytrace():
+    output = run(sys.executable, pypypath, '-S',
+                 stdin="__pytrace__ = 1\nx = 5\nx")
+    assert ('\t<module>:           LOAD_CONST    0 (5)\n'
+            '\t<module>:           STORE_NAME    0 (x)\n'
+            '\t<module>:           LOAD_CONST    1 (None)\n'
+            '\t<module>:           RETURN_VALUE    0 \n'
+            '>>>> ') in output
+    assert ('\t<module>:           LOAD_NAME    0 (x)\n'
+            '\t<module>:           PRINT_EXPR    0 \n'
+            # '5\n' --- this line sent to stderr
+            '\t<module>:           LOAD_CONST    0 (None)\n'
+            '\t<module>:           RETURN_VALUE    0 \n'
+            '>>>> ') in output


More information about the pypy-commit mailing list