diff options
author | Walter Dörwald <walter@livinglogic.de> | 2005-11-25 15:22:10 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2005-11-25 15:22:10 (GMT) |
commit | 9356fb9881ac774e496f08f12a9e166c417feabe (patch) | |
tree | 6cfc792cb15e3de7949ba8f99586e68e1f2c074c | |
parent | 212a5752424631438ae2a8a6ba3d4af22a1c4dd7 (diff) | |
download | cpython-9356fb9881ac774e496f08f12a9e166c417feabe.zip cpython-9356fb9881ac774e496f08f12a9e166c417feabe.tar.gz cpython-9356fb9881ac774e496f08f12a9e166c417feabe.tar.bz2 |
SF patch #1364545: test_cmd_line.py relied on english error messages when
invoking the Python interpreter (which didn't work on non-english Windows
versions). Check return codes instead.
-rw-r--r-- | Lib/test/test_cmd_line.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index ccf7081..43c2ddd 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -2,6 +2,7 @@ import test.test_support, unittest import sys import popen2 +import subprocess class CmdLineTest(unittest.TestCase): def start_python(self, cmd_line): @@ -11,21 +12,19 @@ class CmdLineTest(unittest.TestCase): outfp.close() return data + def exit_code(self, cmd_line): + return subprocess.call([sys.executable, cmd_line], stderr=subprocess.PIPE) + def test_directories(self): - # Does this test make sense? The message for "< ." may depend on - # the command shell, and the message for "." depends on the OS. - if sys.platform.startswith("win"): - # On WinXP w/ cmd.exe, - # "< ." gives "Access is denied.\n" - # "." gives "C:\\Code\\python\\PCbuild\\python.exe: " + - # "can't open file '.':" + - # "[Errno 13] Permission denied\n" - lookfor = " denied" # common to both cases + if sys.platform == 'win32': + # Exit code for "python .", Error 13: permission denied = 2 + expected_exit_code = 2 else: - # This is what the test looked for originally, on all platforms. - lookfor = "is a directory" - self.assertTrue(lookfor in self.start_python('.')) - self.assertTrue(lookfor in self.start_python('< .')) + # Linux has no problem with "python .", Exit code = 0 + expected_exit_code = 0 + self.assertEqual(self.exit_code('.'), expected_exit_code) + + self.assertTrue(self.exit_code('< .') != 0) def verify_valid_flag(self, cmd_line): data = self.start_python(cmd_line) |