diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-10-15 21:50:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-15 21:50:55 (GMT) |
commit | ea75187c68b374bb839f1172f310b206044bc3e5 (patch) | |
tree | 7a66ed107e6cd08533f619f60752c19710fe5030 /Lib/test/test_cmd_line_script.py | |
parent | 43a5bd7b458f0ad2d62b00b033d025689d48d591 (diff) | |
download | cpython-ea75187c68b374bb839f1172f310b206044bc3e5.zip cpython-ea75187c68b374bb839f1172f310b206044bc3e5.tar.gz cpython-ea75187c68b374bb839f1172f310b206044bc3e5.tar.bz2 |
bpo-34783: Fix test_nonexisting_script() (GH-9896)
Fix test_cmd_line_script.test_nonexisting_script(): the test must not
rely on sys.executable, since main.c uses config->program which can
be different than sys.executable in many cases (for example, on macOS
when using the framework).
Diffstat (limited to 'Lib/test/test_cmd_line_script.py')
-rw-r--r-- | Lib/test/test_cmd_line_script.py | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index 4f5af37..5ec9bbb 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -630,8 +630,6 @@ class CmdLineTest(unittest.TestCase): traceback_lines = stderr.decode().splitlines() self.assertIn("No module named script_pkg", traceback_lines[-1]) - @unittest.skipIf(sys.platform == 'darwin' and sys._framework, - "test not valid for macOS framework builds") def test_nonexisting_script(self): # bpo-34783: "./python script.py" must not crash # if the script file doesn't exist. @@ -639,17 +637,12 @@ class CmdLineTest(unittest.TestCase): # is not the actual Python executable file name. script = 'nonexistingscript.py' self.assertFalse(os.path.exists(script)) - # Only test the base name, since the error message can use - # a relative path, whereas sys.executable can be an asolution path. - program = os.path.basename(sys.executable) proc = spawn_python(script, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = proc.communicate() - # "./python" must be in the error message: - # "./python: can't open file (...)" - self.assertIn(program, err) + self.assertIn(": can't open file ", err) self.assertNotEqual(proc.returncode, 0) |