(self)
| 973 | 'Test is not venv-compatible') |
| 974 | @support.requires_subprocess() |
| 975 | def test_executable(self): |
| 976 | # sys.executable should be absolute |
| 977 | self.assertEqual(os.path.abspath(sys.executable), sys.executable) |
| 978 | |
| 979 | # Issue #7774: Ensure that sys.executable is an empty string if argv[0] |
| 980 | # has been set to a non existent program name and Python is unable to |
| 981 | # retrieve the real program name |
| 982 | |
| 983 | # For a normal installation, it should work without 'cwd' |
| 984 | # argument. For test runs in the build directory, see #7774. |
| 985 | python_dir = os.path.dirname(os.path.realpath(sys.executable)) |
| 986 | p = subprocess.Popen( |
| 987 | ["nonexistent", "-c", |
| 988 | 'import sys; print(sys.executable.encode("ascii", "backslashreplace"))'], |
| 989 | executable=sys.executable, stdout=subprocess.PIPE, cwd=python_dir) |
| 990 | stdout = p.communicate()[0] |
| 991 | executable = stdout.strip().decode("ASCII") |
| 992 | p.wait() |
| 993 | self.assertIn(executable, ["b''", repr(sys.executable.encode("ascii", "backslashreplace"))]) |
| 994 | |
| 995 | def check_fsencoding(self, fs_encoding, expected=None): |
| 996 | self.assertIsNotNone(fs_encoding) |
nothing calls this directly
no test coverage detected