MCPcopy Index your code
hub / github.com/python/cpython / test_executable

Method test_executable

Lib/test/test_sys.py:975–993  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 10

communicateMethod · 0.95
waitMethod · 0.95
assertInMethod · 0.80
assertEqualMethod · 0.45
abspathMethod · 0.45
dirnameMethod · 0.45
realpathMethod · 0.45
decodeMethod · 0.45
stripMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected