From: <pj...@us...> - 2009-02-03 20:20:02
|
Revision: 6008 http://jython.svn.sourceforge.net/jython/?rev=6008&view=rev Author: pjenvey Date: 2009-02-03 20:19:57 +0000 (Tue, 03 Feb 2009) Log Message: ----------- fix test_version per r6003 Modified Paths: -------------- trunk/jython/Lib/test/test_cmd_line.py Modified: trunk/jython/Lib/test/test_cmd_line.py =================================================================== --- trunk/jython/Lib/test/test_cmd_line.py 2009-02-03 12:01:46 UTC (rev 6007) +++ trunk/jython/Lib/test/test_cmd_line.py 2009-02-03 20:19:57 UTC (rev 6008) @@ -45,11 +45,8 @@ self.assertTrue('usage' in self.start_python('-h')) def test_version(self): - from org.python.util import InteractiveConsole - expected = InteractiveConsole.getDefaultBanner() - reported = self.start_python('-V') - self.assertTrue(reported.startswith(expected), - "-V should start with '%s' but it printed '%s'" % (expected, reported)) + version = 'Jython %d.%d' % sys.version_info[:2] + self.assertTrue(self.start_python('-V').startswith(version)) def test_main(): test.test_support.run_unittest(CmdLineTest) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-11 00:25:05
|
Revision: 6212 http://jython.svn.sourceforge.net/jython/?rev=6212&view=rev Author: pjenvey Date: 2009-04-11 00:24:56 +0000 (Sat, 11 Apr 2009) Log Message: ----------- from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_cmd_line.py@54387 Modified Paths: -------------- trunk/jython/Lib/test/test_cmd_line.py Modified: trunk/jython/Lib/test/test_cmd_line.py =================================================================== --- trunk/jython/Lib/test/test_cmd_line.py 2009-04-10 23:09:34 UTC (rev 6211) +++ trunk/jython/Lib/test/test_cmd_line.py 2009-04-11 00:24:56 UTC (rev 6212) @@ -1,4 +1,3 @@ -# from CPython 2.4, changing Python to Jython in test_version import test.test_support, unittest import sys @@ -7,14 +6,20 @@ class CmdLineTest(unittest.TestCase): def start_python(self, cmd_line): - outfp, infp = popen2.popen4('%s %s' % (sys.executable, cmd_line)) + outfp, infp = popen2.popen4('"%s" %s' % (sys.executable, cmd_line)) infp.close() data = outfp.read() outfp.close() + # try to cleanup the child so we don't appear to leak when running + # with regrtest -R. This should be a no-op on Windows. + popen2._cleanup() return data - def exit_code(self, cmd_line): - return subprocess.call([sys.executable, cmd_line], stderr=subprocess.PIPE) + def exit_code(self, *args): + cmd_line = [sys.executable] + cmd_line.extend(args) + return subprocess.call(cmd_line, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) def test_directories(self): self.assertNotEqual(self.exit_code('.'), 0) @@ -22,7 +27,7 @@ def verify_valid_flag(self, cmd_line): data = self.start_python(cmd_line) - self.assertTrue(data == '' or data.endswith('\n'), repr(data)) + self.assertTrue(data == '' or data.endswith('\n')) self.assertTrue('Traceback' not in data) def test_environment(self): @@ -42,16 +47,47 @@ self.verify_valid_flag('-S') def test_usage(self): - result = self.start_python('-h') - self.assertTrue('usage' in result, repr(result)) + self.assertTrue('usage' in self.start_python('-h')) def test_version(self): - version = 'Jython %d.%d' % sys.version_info[:2] - result = self.start_python('-V') - self.assertTrue(result.startswith(version), repr(result)) + version = 'Python %d.%d' % sys.version_info[:2] + self.assertTrue(self.start_python('-V').startswith(version)) + def test_run_module(self): + # Test expected operation of the '-m' switch + # Switch needs an argument + self.assertNotEqual(self.exit_code('-m'), 0) + # Check we get an error for a nonexistent module + self.assertNotEqual( + self.exit_code('-m', 'fnord43520xyz'), + 0) + # Check the runpy module also gives an error for + # a nonexistent module + self.assertNotEqual( + self.exit_code('-m', 'runpy', 'fnord43520xyz'), + 0) + # All good if module is located and run successfully + self.assertEqual( + self.exit_code('-m', 'timeit', '-n', '1'), + 0) + + def test_run_code(self): + # Test expected operation of the '-c' switch + # Switch needs an argument + self.assertNotEqual(self.exit_code('-c'), 0) + # Check we get an error for an uncaught exception + self.assertNotEqual( + self.exit_code('-c', 'raise Exception'), + 0) + # All good if execution is successful + self.assertEqual( + self.exit_code('-c', 'pass'), + 0) + + def test_main(): test.test_support.run_unittest(CmdLineTest) + test.test_support.reap_children() if __name__ == "__main__": test_main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-22 02:41:20
|
Revision: 6363 http://jython.svn.sourceforge.net/jython/?rev=6363&view=rev Author: pjenvey Date: 2009-05-22 02:41:04 +0000 (Fri, 22 May 2009) Log Message: ----------- don't use subprocess.call with PIPEs. it only wait()s -- without consuming those pipes, their buffers can fill and cause a chatty child (like test_run_module with the smaller Windows PIPE_BUF) to deadlock fixes #1351 Modified Paths: -------------- trunk/jython/Lib/test/test_cmd_line.py Modified: trunk/jython/Lib/test/test_cmd_line.py =================================================================== --- trunk/jython/Lib/test/test_cmd_line.py 2009-05-21 06:04:58 UTC (rev 6362) +++ trunk/jython/Lib/test/test_cmd_line.py 2009-05-22 02:41:04 UTC (rev 6363) @@ -1,4 +1,4 @@ - +import os import test.test_support, unittest import sys import popen2 @@ -18,8 +18,11 @@ def exit_code(self, *args): cmd_line = [sys.executable] cmd_line.extend(args) - return subprocess.call(cmd_line, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + devnull = open(os.devnull, 'w') + result = subprocess.call(cmd_line, stdout=devnull, + stderr=subprocess.STDOUT) + devnull.close() + return result def test_directories(self): self.assertNotEqual(self.exit_code('.'), 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |