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

Method test_registry_win32

Lib/test/test_getpath.py:111–158  ·  view source on GitHub ↗

Test registry lookup on Windows. On Windows there are registry entries that are intended for other applications to register search paths.

(self)

Source from the content-addressed store, hash-verified

109 self.assertEqual(expected, actual)
110
111 def test_registry_win32(self):
112 """Test registry lookup on Windows.
113
114 On Windows there are registry entries that are intended for other
115 applications to register search paths.
116 """
117 hkey = rf"HKLM\Software\Python\PythonCore\9.8-XY\PythonPath"
118 winreg = MockWinreg({
119 hkey: None,
120 f"{hkey}\\Path1": "path1-dir",
121 f"{hkey}\\Path1\\Subdir": "not-subdirs",
122 })
123 ns = MockNTNamespace(
124 argv0=r"C:\Python\python.exe",
125 real_executable=r"C:\Python\python.exe",
126 winreg=winreg,
127 )
128 ns.add_known_xfile(r"C:\Python\python.exe")
129 ns.add_known_file(r"C:\Python\Lib\os.py")
130 ns.add_known_dir(r"C:\Python\DLLs")
131 expected = dict(
132 module_search_paths_set=1,
133 module_search_paths=[
134 r"C:\Python\python98.zip",
135 "path1-dir",
136 # should not contain not-subdirs
137 r"C:\Python\DLLs",
138 r"C:\Python\Lib",
139 r"C:\Python",
140 ],
141 )
142 actual = getpath(ns, expected)
143 self.assertEqual(expected, actual)
144
145 ns["config"]["use_environment"] = 0
146 ns["config"]["module_search_paths_set"] = 0
147 ns["config"]["module_search_paths"] = None
148 expected = dict(
149 module_search_paths_set=1,
150 module_search_paths=[
151 r"C:\Python\python98.zip",
152 r"C:\Python\DLLs",
153 r"C:\Python\Lib",
154 r"C:\Python",
155 ],
156 )
157 actual = getpath(ns, expected)
158 self.assertEqual(expected, actual)
159
160 def test_symlink_normal_win32(self):
161 "Test a 'standard' install layout via symlink on Windows."

Callers

nothing calls this directly

Calls 7

add_known_xfileMethod · 0.95
add_known_fileMethod · 0.95
add_known_dirMethod · 0.95
MockWinregClass · 0.85
MockNTNamespaceClass · 0.85
getpathFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected