From: <pj...@us...> - 2009-05-05 02:14:42
|
Revision: 6295 http://jython.svn.sourceforge.net/jython/?rev=6295&view=rev Author: pjenvey Date: 2009-05-05 01:31:30 +0000 (Tue, 05 May 2009) Log Message: ----------- small cleanup Modified Paths: -------------- trunk/jython/Lib/subprocess.py trunk/jython/Lib/test/test_subprocess_jy.py Modified: trunk/jython/Lib/subprocess.py =================================================================== --- trunk/jython/Lib/subprocess.py 2009-05-04 12:09:44 UTC (rev 6294) +++ trunk/jython/Lib/subprocess.py 2009-05-05 01:31:30 UTC (rev 6295) @@ -1107,8 +1107,8 @@ pass elif stderr == PIPE: errread = PIPE - elif stderr == STDOUT or \ - isinstance(stderr, org.python.core.io.RawIOBase): + elif (stderr == STDOUT or + isinstance(stderr, org.python.core.io.RawIOBase)): errwrite = stderr else: # Assuming file-like object @@ -1123,8 +1123,8 @@ """Determine if the subprocess' stderr should be redirected to stdout """ - return errwrite == STDOUT or c2pwrite not in (None, PIPE) and \ - c2pwrite is errwrite + return (errwrite == STDOUT or c2pwrite not in (None, PIPE) and + c2pwrite is errwrite) def _coupler_thread(self, *args, **kwargs): @@ -1164,9 +1164,9 @@ raise OSError(iae.getMessage() or iae) if env is None: - # This is for compatibility with the CPython implementation, - # that ends up calling os.execvp(). So os.environ is "inherited" - # there if env is not explicitly set. + # For compatibility with CPython which calls + # os.execvp(). os.environ is "inherited" there if env is + # not explicitly set env = os.environ builder_env = builder.environment() @@ -1563,9 +1563,9 @@ # print "Running a jython subprocess to return the number of processors..." p = Popen([sys.executable, "-c", - 'import sys;' \ - 'from java.lang import Runtime;' \ - 'sys.exit(Runtime.getRuntime().availableProcessors())']) + ('import sys;' + 'from java.lang import Runtime;' + 'sys.exit(Runtime.getRuntime().availableProcessors())')]) print p.wait() # @@ -1573,15 +1573,15 @@ # print "Connecting two jython subprocesses..." p1 = Popen([sys.executable, "-c", - 'import os;' \ - 'print os.environ["foo"]'], env=dict(foo='bar'), + ('import os;' + 'print os.environ["foo"]')], env=dict(foo='bar'), stdout=PIPE) p2 = Popen([sys.executable, "-c", - 'import os, sys;' \ - 'their_foo = sys.stdin.read().strip();' \ - 'my_foo = os.environ["foo"];' \ - 'msg = "Their env\'s foo: %r, My env\'s foo: %r";' \ - 'print msg % (their_foo, my_foo)'], + ('import os, sys;' + 'their_foo = sys.stdin.read().strip();' + 'my_foo = os.environ["foo"];' + 'msg = "Their env\'s foo: %r, My env\'s foo: %r";' + 'print msg % (their_foo, my_foo)')], env=dict(foo='baz'), stdin=p1.stdout, stdout=PIPE) print p2.communicate()[0] Modified: trunk/jython/Lib/test/test_subprocess_jy.py =================================================================== --- trunk/jython/Lib/test/test_subprocess_jy.py 2009-05-04 12:09:44 UTC (rev 6294) +++ trunk/jython/Lib/test/test_subprocess_jy.py 2009-05-05 01:31:30 UTC (rev 6295) @@ -1,4 +1,4 @@ -"Tests for cmp() compatibility with CPython" +"""Misc subprocess tests""" import unittest import os import sys @@ -6,6 +6,7 @@ from subprocess import Popen, PIPE class EnvironmentInheritanceTest(unittest.TestCase): + def testDefaultEnvIsInherited(self): # Test for issue #1104 os.environ['foo'] = 'something' @@ -15,8 +16,12 @@ self.assertEquals('something', p1.stdout.read()) -# tests for (some parts of) issue #1187: JYTHON_OPTS should not be enriched by arguments class JythonOptsTest(unittest.TestCase): + + """ Tests for (some parts of) issue #1187: JYTHON_OPTS should not be + enriched by arguments + """ + def testNoJythonOpts(self): os.environ['JYTHON_OPTS'] = '' p1 = Popen([sys.executable, "-c", @@ -32,12 +37,11 @@ stdout=PIPE) self.assertEquals(options, p1.stdout.read()) + def test_main(): - test_classes = ( - EnvironmentInheritanceTest, - JythonOptsTest, - ) - test_support.run_unittest(*test_classes) + test_support.run_unittest(EnvironmentInheritanceTest, + JythonOptsTest) + if __name__ == '__main__': test_main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |