Commit 9356fb98 authored by Walter Dörwald's avatar Walter Dörwald

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.
parent 212a5752
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import test.test_support, unittest import test.test_support, unittest
import sys import sys
import popen2 import popen2
import subprocess
class CmdLineTest(unittest.TestCase): class CmdLineTest(unittest.TestCase):
def start_python(self, cmd_line): def start_python(self, cmd_line):
...@@ -11,21 +12,19 @@ class CmdLineTest(unittest.TestCase): ...@@ -11,21 +12,19 @@ class CmdLineTest(unittest.TestCase):
outfp.close() outfp.close()
return data return data
def exit_code(self, cmd_line):
return subprocess.call([sys.executable, cmd_line], stderr=subprocess.PIPE)
def test_directories(self): def test_directories(self):
# Does this test make sense? The message for "< ." may depend on if sys.platform == 'win32':
# the command shell, and the message for "." depends on the OS. # Exit code for "python .", Error 13: permission denied = 2
if sys.platform.startswith("win"): expected_exit_code = 2
# 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
else: else:
# This is what the test looked for originally, on all platforms. # Linux has no problem with "python .", Exit code = 0
lookfor = "is a directory" expected_exit_code = 0
self.assertTrue(lookfor in self.start_python('.')) self.assertEqual(self.exit_code('.'), expected_exit_code)
self.assertTrue(lookfor in self.start_python('< .'))
self.assertTrue(self.exit_code('< .') != 0)
def verify_valid_flag(self, cmd_line): def verify_valid_flag(self, cmd_line):
data = self.start_python(cmd_line) data = self.start_python(cmd_line)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment