Show More
@@ -198,12 +198,11 b' def get_home_dir(require_writable=False) -> str:' | |||
|
198 | 198 | # expanduser failed, use the registry to get the 'My Documents' folder. |
|
199 | 199 | try: |
|
200 | 200 | import winreg as wreg |
|
201 |
|
|
|
201 | with wreg.OpenKey( | |
|
202 | 202 | wreg.HKEY_CURRENT_USER, |
|
203 | 203 | r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" |
|
204 | ) | |
|
205 | homedir = wreg.QueryValueEx(key,'Personal')[0] | |
|
206 | key.Close() | |
|
204 | ) as key: | |
|
205 | homedir = wreg.QueryValueEx(key,'Personal')[0] | |
|
207 | 206 | except: |
|
208 | 207 | pass |
|
209 | 208 |
@@ -171,8 +171,12 b' def test_get_home_dir_8():' | |||
|
171 | 171 | env.pop(key, None) |
|
172 | 172 | |
|
173 | 173 | class key: |
|
174 | def __enter__(self): | |
|
175 | pass | |
|
174 | 176 | def Close(self): |
|
175 | 177 | pass |
|
178 | def __exit__(*args, **kwargs): | |
|
179 | pass | |
|
176 | 180 | |
|
177 | 181 | with patch.object(wreg, 'OpenKey', return_value=key()), \ |
|
178 | 182 | patch.object(wreg, 'QueryValueEx', return_value=[abspath(HOME_TEST_DIR)]): |
General Comments 0
You need to be logged in to leave comments.
Login now