[pypy-svn] r40823 - in pypy/dist/pypy/translator/goal: . test2

arigo at codespeak.net arigo at codespeak.net
Tue Mar 20 12:27:11 CET 2007


Author: arigo
Date: Tue Mar 20 12:27:09 2007
New Revision: 40823

Modified:
   pypy/dist/pypy/translator/goal/app_main.py
   pypy/dist/pypy/translator/goal/test2/test_app_main.py
Log:
Fix for the case of "-u -i" options.


Modified: pypy/dist/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/dist/pypy/translator/goal/app_main.py	(original)
+++ pypy/dist/pypy/translator/goal/app_main.py	Tue Mar 20 12:27:09 2007
@@ -267,7 +267,7 @@
                 runpy.run_module(sys.argv[0], None, '__main__', True)
             success = run_toplevel(run_it)
         elif run_stdin:
-            if sys.stdin.isatty():
+            if go_interactive or sys.stdin.isatty():
                 print_banner()
                 python_startup = os.getenv('PYTHONSTARTUP')
                 if python_startup:

Modified: pypy/dist/pypy/translator/goal/test2/test_app_main.py
==============================================================================
--- pypy/dist/pypy/translator/goal/test2/test_app_main.py	(original)
+++ pypy/dist/pypy/translator/goal/test2/test_app_main.py	Tue Mar 20 12:27:09 2007
@@ -233,6 +233,19 @@
         child.sendline('"pypy.translator.goal.test2.mymodule" in sys.modules')
         child.expect('False')
 
+    def test_options_u_i(self):
+        import subprocess, select, os
+        python = sys.executable
+        pipe = subprocess.Popen([python, app_main, "-u", "-i"],
+                                stdout=subprocess.PIPE,
+                                stdin=subprocess.PIPE,
+                                stderr=subprocess.STDOUT,
+                                bufsize=0, close_fds=True)
+        iwtd, owtd, ewtd = select.select([pipe.stdout], [], [], 5)
+        assert iwtd    # else we timed out
+        data = os.read(pipe.stdout.fileno(), 1024)
+        assert data.startswith('Python')
+
 
 class TestNonInteractive:
 
@@ -296,24 +309,3 @@
         assert 'Name: __main__' in data
         assert ('File: ' + p) in data
         assert ('Argv: ' + repr([p, 'extra'])) in data
-
-def test_option_u():
-    py.test.skip("Failing")
-    import subprocess
-    from py.__.green.greensock2 import autogreenlet, Timer, Interrupted
-    from py.__.green.pipe.fd import FDInput
-    python = "python"
-    pipe = subprocess.Popen([python, app_main, "-u", "-i"],
-                            stdout=subprocess.PIPE,
-                            stdin=subprocess.PIPE, stderr=subprocess.STDOUT,
-                            bufsize=0, close_fds=True)
-    read_fd = FDInput(pipe.stdout.fileno(), close=False)
-    timeout = 5
-    timer = Timer(timeout)
-    try:
-        data = read_fd.recv(10024)
-    except Interrupted:
-        py.test.fail("Timed out reading")
-    else:
-        timer.stop()
-



More information about the Pypy-commit mailing list