[Python-checkins] cpython: Add unittests demonstrating issue #11432.

gregory.p.smith python-checkins at python.org
Tue Mar 15 20:52:39 CET 2011


http://hg.python.org/cpython/rev/08daf3ef6509
changeset:   68519:08daf3ef6509
parent:      68500:a6390ebff835
user:        Gregory P. Smith <greg at krypto.org>
date:        Tue Mar 15 14:55:17 2011 -0400
summary:
  Add unittests demonstrating issue #11432.

files:
  Lib/test/test_subprocess.py

diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -3,6 +3,7 @@
 import subprocess
 import sys
 import signal
+import io
 import os
 import errno
 import tempfile
@@ -1256,6 +1257,24 @@
                         close_fds=False, pass_fds=(fd, )))
             self.assertIn('overriding close_fds', str(context.warning))
 
+    def test_stdout_stdin_are_single_inout_fd(self):
+        with io.open(os.devnull, "r+") as inout:
+            p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"],
+                                 stdout=inout, stdin=inout)
+            p.wait()
+
+    def test_stdout_stderr_are_single_inout_fd(self):
+        with io.open(os.devnull, "r+") as inout:
+            p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"],
+                                 stdout=inout, stderr=inout)
+            p.wait()
+
+    def test_stderr_stdin_are_single_inout_fd(self):
+        with io.open(os.devnull, "r+") as inout:
+            p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"],
+                                 stderr=inout, stdin=inout)
+            p.wait()
+
     def test_wait_when_sigchild_ignored(self):
         # NOTE: sigchild_ignore.py may not be an effective test on all OSes.
         sigchild_ignore = support.findfile("sigchild_ignore.py",
@@ -1528,19 +1547,6 @@
                 raise c.exception
 
 
-def test_main():
-    unit_tests = (ProcessTestCase,
-                  POSIXProcessTestCase,
-                  Win32ProcessTestCase,
-                  ProcessTestCasePOSIXPurePython,
-                  CommandTests,
-                  ProcessTestCaseNoPoll,
-                  HelperFunctionTests,
-                  CommandsWithSpaces,
-                  ContextManagerTests)
-
-    support.run_unittest(*unit_tests)
+if __name__ == "__main__":
+    unittest.main()
     support.reap_children()
-
-if __name__ == "__main__":
-    test_main()

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list