Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
restore tests
  • Loading branch information
picnixz committed May 8, 2025
commit bed1018116f3a50eee07418cd444583dbb722bb8
37 changes: 37 additions & 0 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,43 @@ def test_getpath_abspath_win32(self):
for (_, expected), result in zip(CASES, results):
self.assertEqual(result, expected)

def test_global_pathconfig(self):
# Test C API functions getting the path configuration:
#
# - Py_GetExecPrefix()
# - Py_GetPath()
# - Py_GetPrefix()
# - Py_GetProgramFullPath()
# - Py_GetProgramName()
# - Py_GetPythonHome()
#
# The global path configuration (_Py_path_config) must be a copy
# of the path configuration of PyInterpreter.config (PyConfig).
ctypes = import_helper.import_module('ctypes')

def get_func(name):
func = getattr(ctypes.pythonapi, name)
func.argtypes = ()
func.restype = ctypes.c_wchar_p
return func

Py_GetPath = get_func('Py_GetPath')
Py_GetPrefix = get_func('Py_GetPrefix')
Py_GetExecPrefix = get_func('Py_GetExecPrefix')
Py_GetProgramName = get_func('Py_GetProgramName')
Py_GetProgramFullPath = get_func('Py_GetProgramFullPath')
Py_GetPythonHome = get_func('Py_GetPythonHome')

config = _testinternalcapi.get_configs()['config']

self.assertEqual(tuple(Py_GetPath().split(os.path.pathsep)),
config['module_search_paths'])
self.assertEqual(Py_GetPrefix(), config['prefix'])
self.assertEqual(Py_GetExecPrefix(), config['exec_prefix'])
self.assertEqual(Py_GetProgramName(), config['program_name'])
self.assertEqual(Py_GetProgramFullPath(), config['executable'])
self.assertEqual(Py_GetPythonHome(), config['home'])

def test_init_warnoptions(self):
# lowest to highest priority
warnoptions = [
Expand Down