[Python-checkins] python/dist/src/Lib/test test_subprocess.py, 1.2, 1.3

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Wed Oct 13 00:19:50 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21294/Lib/test

Modified Files:
	test_subprocess.py 
Log Message:
Wrap long lines.


Index: test_subprocess.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_subprocess.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- test_subprocess.py	12 Oct 2004 21:51:32 -0000	1.2
+++ test_subprocess.py	12 Oct 2004 22:19:32 -0000	1.3
@@ -14,7 +14,8 @@
 #
 
 if mswindows:
-    SETBINARY = 'import msvcrt; msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY);'
+    SETBINARY = ('import msvcrt; msvcrt.setmode(sys.stdout.fileno(), '
+                                                'os.O_BINARY);')
 else:
     SETBINARY = ''
 
@@ -32,7 +33,8 @@
     #
     def test_call_seq(self):
         """call() function with sequence argument"""
-        rc = subprocess.call([sys.executable, "-c", "import sys; sys.exit(47)"])
+        rc = subprocess.call([sys.executable, "-c",
+                              "import sys; sys.exit(47)"])
         self.assertEqual(rc, 47)
 
     def test_call_kwargs(self):
@@ -68,8 +70,9 @@
 
     def test_executable(self):
         """executable"""
-        p = subprocess.Popen(["somethingyoudonthave", "-c", "import sys; sys.exit(47)"],
-                         executable=sys.executable)
+        p = subprocess.Popen(["somethingyoudonthave",
+                              "-c", "import sys; sys.exit(47)"],
+                             executable=sys.executable)
         p.wait()
         self.assertEqual(p.returncode, 47)
 
@@ -215,14 +218,17 @@
                           'import sys,os;' \
                           'sys.stderr.write("pineapple");' \
                           'sys.stdout.write(sys.stdin.read())'],
-                         stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+                         stdin=subprocess.PIPE,
+                         stdout=subprocess.PIPE,
+                         stderr=subprocess.PIPE)
         (stdout, stderr) = p.communicate("banana")
         self.assertEqual(stdout, "banana")
         self.assertEqual(stderr, "pineapple")
 
     def test_communicate_returns(self):
         """communicate() should return None if no redirection is active"""
-        p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(47)"])
+        p = subprocess.Popen([sys.executable, "-c",
+                              "import sys; sys.exit(47)"])
         (stdout, stderr) = p.communicate()
         self.assertEqual(stdout, None)
         self.assertEqual(stderr, None)
@@ -243,7 +249,9 @@
                           'sys.stdout.write(sys.stdin.read(47));' \
                           'sys.stderr.write("xyz"*%d);' \
                           'sys.stdout.write(sys.stdin.read())' % pipe_buf],
-                         stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+                         stdin=subprocess.PIPE,
+                         stdout=subprocess.PIPE,
+                         stderr=subprocess.PIPE)
         string_to_write = "abc"*pipe_buf
         (stdout, stderr) = p.communicate(string_to_write)
         self.assertEqual(stdout, string_to_write)
@@ -253,7 +261,9 @@
         p = subprocess.Popen([sys.executable, "-c",
                           'import sys,os;' \
                           'sys.stdout.write(sys.stdin.read())'],
-                         stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+                         stdin=subprocess.PIPE,
+                         stdout=subprocess.PIPE,
+                         stderr=subprocess.PIPE)
         p.stdin.write("banana")
         (stdout, stderr) = p.communicate("split")
         self.assertEqual(stdout, "bananasplit")
@@ -262,49 +272,52 @@
     def test_universal_newlines(self):
         """universal newlines"""
         p = subprocess.Popen([sys.executable, "-c",
-                          'import sys,os;' + SETBINARY + \
-                          'sys.stdout.write("line1\\n");' \
-                          'sys.stdout.flush();' \
-                          'sys.stdout.write("line2\\r");' \
-                          'sys.stdout.flush();' \
-                          'sys.stdout.write("line3\\r\\n");' \
-                          'sys.stdout.flush();' \
-                          'sys.stdout.write("line4\\r");' \
-                          'sys.stdout.flush();' \
+                          'import sys,os;' + SETBINARY +
+                          'sys.stdout.write("line1\\n");'
+                          'sys.stdout.flush();'
+                          'sys.stdout.write("line2\\r");'
+                          'sys.stdout.flush();'
+                          'sys.stdout.write("line3\\r\\n");'
+                          'sys.stdout.flush();'
+                          'sys.stdout.write("line4\\r");'
+                          'sys.stdout.flush();'
                           'sys.stdout.write("\\nline5");'
-                          'sys.stdout.flush();' \
+                          'sys.stdout.flush();'
                           'sys.stdout.write("\\nline6");'],
                          stdout=subprocess.PIPE,
                          universal_newlines=1)
         stdout = p.stdout.read()
         if hasattr(open, 'newlines'):
             # Interpreter with universal newline support
-            self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6")
+            self.assertEqual(stdout,
+                             "line1\nline2\nline3\nline4\nline5\nline6")
         else:
             # Interpreter without universal newline support
-            self.assertEqual(stdout, "line1\nline2\rline3\r\nline4\r\nline5\nline6")
+            self.assertEqual(stdout,
+                             "line1\nline2\rline3\r\nline4\r\nline5\nline6")
 
     def test_universal_newlines_communicate(self):
         """universal newlines through communicate()"""
         p = subprocess.Popen([sys.executable, "-c",
-                          'import sys,os;' + SETBINARY + \
-                          'sys.stdout.write("line1\\n");' \
-                          'sys.stdout.flush();' \
-                          'sys.stdout.write("line2\\r");' \
-                          'sys.stdout.flush();' \
-                          'sys.stdout.write("line3\\r\\n");' \
-                          'sys.stdout.flush();' \
-                          'sys.stdout.write("line4\\r");' \
-                          'sys.stdout.flush();' \
+                          'import sys,os;' + SETBINARY +
+                          'sys.stdout.write("line1\\n");'
+                          'sys.stdout.flush();'
+                          'sys.stdout.write("line2\\r");'
+                          'sys.stdout.flush();'
+                          'sys.stdout.write("line3\\r\\n");'
+                          'sys.stdout.flush();'
+                          'sys.stdout.write("line4\\r");'
+                          'sys.stdout.flush();'
                           'sys.stdout.write("\\nline5");'
-                          'sys.stdout.flush();' \
+                          'sys.stdout.flush();'
                           'sys.stdout.write("\\nline6");'],
                          stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                          universal_newlines=1)
         (stdout, stderr) = p.communicate()
         if hasattr(open, 'newlines'):
             # Interpreter with universal newline support
-            self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6")
+            self.assertEqual(stdout,
+                             "line1\nline2\nline3\nline4\nline5\nline6")
         else:
             # Interpreter without universal newline support
             self.assertEqual(stdout, "line1\nline2\rline3\r\nline4\r\nline5\nline6")
@@ -312,8 +325,11 @@
     def test_no_leaking(self):
         """Make sure we leak no resources"""
         for i in range(1026):
-            p = subprocess.Popen([sys.executable, "-c", "import sys;sys.stdout.write(sys.stdin.read())"],
-                             stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+            p = subprocess.Popen([sys.executable, "-c",
+                    "import sys;sys.stdout.write(sys.stdin.read())"],
+                    stdin=subprocess.PIPE,
+                    stdout=subprocess.PIPE,
+                    stderr=subprocess.PIPE)
             data = p.communicate("lime")[0]
             self.assertEqual(data, "lime")
 
@@ -373,7 +389,8 @@
 
         def test_run_abort(self):
             """returncode handles signal termination"""
-            p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"])
+            p = subprocess.Popen([sys.executable,
+                                  "-c", "import os; os.abort()"])
             p.wait()
             self.assertEqual(-p.returncode, signal.SIGABRT)
 
@@ -401,7 +418,8 @@
             """args is a string"""
             f, fname = self.mkstemp()
             os.write(f, "#!/bin/sh\n")
-            os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" % sys.executable)
+            os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" %
+                        sys.executable)
             os.close(f)
             os.chmod(fname, 0700)
             p = subprocess.Popen(fname)
@@ -412,10 +430,12 @@
         def test_invalid_args(self):
             """invalid arguments should raise ValueError"""
             self.assertRaises(ValueError, subprocess.call,
-                              [sys.executable, "-c", "import sys; sys.exit(47)"],
+                              [sys.executable,
+                               "-c", "import sys; sys.exit(47)"],
                               startupinfo=47)
             self.assertRaises(ValueError, subprocess.call,
-                              [sys.executable, "-c", "import sys; sys.exit(47)"],
+                              [sys.executable,
+                               "-c", "import sys; sys.exit(47)"],
                               creationflags=47)
 
         def test_shell_sequence(self):
@@ -440,7 +460,8 @@
             """call() function with string argument on UNIX"""
             f, fname = self.mkstemp()
             os.write(f, "#!/bin/sh\n")
-            os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" % sys.executable)
+            os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" %
+                        sys.executable)
             os.close(f)
             os.chmod(fname, 0700)
             rc = subprocess.call(fname)
@@ -469,16 +490,19 @@
         def test_creationflags(self):
             """creationflags argument"""
             CREATE_NEW_CONSOLE = 16
-            subprocess.call(sys.executable + ' -c "import time; time.sleep(2)"',
+            subprocess.call(sys.executable +
+                                ' -c "import time; time.sleep(2)"',
                             creationflags=CREATE_NEW_CONSOLE)
 
         def test_invalid_args(self):
             """invalid arguments should raise ValueError"""
             self.assertRaises(ValueError, subprocess.call,
-                              [sys.executable, "-c", "import sys; sys.exit(47)"],
+                              [sys.executable,
+                               "-c", "import sys; sys.exit(47)"],
                               preexec_fn=lambda: 1)
             self.assertRaises(ValueError, subprocess.call,
-                              [sys.executable, "-c", "import sys; sys.exit(47)"],
+                              [sys.executable,
+                               "-c", "import sys; sys.exit(47)"],
                               close_fds=True)
 
         def test_shell_sequence(self):
@@ -501,11 +525,11 @@
 
         def test_call_string(self):
             """call() function with string argument on Windows"""
-            rc = subprocess.call(sys.executable + ' -c "import sys; sys.exit(47)"')
+            rc = subprocess.call(sys.executable +
+                                 ' -c "import sys; sys.exit(47)"')
             self.assertEqual(rc, 47)
 
 
-
 def test_main():
     test_support.run_unittest(ProcessTestCase)
 



More information about the Python-checkins mailing list