Skip to content

Commit bed1018

Browse files
committed
restore tests
1 parent 58ab9bd commit bed1018

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Lib/test/test_embed.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,43 @@ def test_getpath_abspath_win32(self):
17051705
for (_, expected), result in zip(CASES, results):
17061706
self.assertEqual(result, expected)
17071707

1708+
def test_global_pathconfig(self):
1709+
# Test C API functions getting the path configuration:
1710+
#
1711+
# - Py_GetExecPrefix()
1712+
# - Py_GetPath()
1713+
# - Py_GetPrefix()
1714+
# - Py_GetProgramFullPath()
1715+
# - Py_GetProgramName()
1716+
# - Py_GetPythonHome()
1717+
#
1718+
# The global path configuration (_Py_path_config) must be a copy
1719+
# of the path configuration of PyInterpreter.config (PyConfig).
1720+
ctypes = import_helper.import_module('ctypes')
1721+
1722+
def get_func(name):
1723+
func = getattr(ctypes.pythonapi, name)
1724+
func.argtypes = ()
1725+
func.restype = ctypes.c_wchar_p
1726+
return func
1727+
1728+
Py_GetPath = get_func('Py_GetPath')
1729+
Py_GetPrefix = get_func('Py_GetPrefix')
1730+
Py_GetExecPrefix = get_func('Py_GetExecPrefix')
1731+
Py_GetProgramName = get_func('Py_GetProgramName')
1732+
Py_GetProgramFullPath = get_func('Py_GetProgramFullPath')
1733+
Py_GetPythonHome = get_func('Py_GetPythonHome')
1734+
1735+
config = _testinternalcapi.get_configs()['config']
1736+
1737+
self.assertEqual(tuple(Py_GetPath().split(os.path.pathsep)),
1738+
config['module_search_paths'])
1739+
self.assertEqual(Py_GetPrefix(), config['prefix'])
1740+
self.assertEqual(Py_GetExecPrefix(), config['exec_prefix'])
1741+
self.assertEqual(Py_GetProgramName(), config['program_name'])
1742+
self.assertEqual(Py_GetProgramFullPath(), config['executable'])
1743+
self.assertEqual(Py_GetPythonHome(), config['home'])
1744+
17081745
def test_init_warnoptions(self):
17091746
# lowest to highest priority
17101747
warnoptions = [

0 commit comments

Comments
 (0)