##// END OF EJS Templates
correct patching ?
Matthias Bussonnier -
Show More
@@ -198,12 +198,11 b' def get_home_dir(require_writable=False) -> str:'
198 # expanduser failed, use the registry to get the 'My Documents' folder.
198 # expanduser failed, use the registry to get the 'My Documents' folder.
199 try:
199 try:
200 import winreg as wreg
200 import winreg as wreg
201 key = wreg.OpenKey(
201 with wreg.OpenKey(
202 wreg.HKEY_CURRENT_USER,
202 wreg.HKEY_CURRENT_USER,
203 r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
203 r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
204 )
204 ) as key:
205 homedir = wreg.QueryValueEx(key,'Personal')[0]
205 homedir = wreg.QueryValueEx(key,'Personal')[0]
206 key.Close()
207 except:
206 except:
208 pass
207 pass
209
208
@@ -171,8 +171,12 b' def test_get_home_dir_8():'
171 env.pop(key, None)
171 env.pop(key, None)
172
172
173 class key:
173 class key:
174 def __enter__(self):
175 pass
174 def Close(self):
176 def Close(self):
175 pass
177 pass
178 def __exit__(*args, **kwargs):
179 pass
176
180
177 with patch.object(wreg, 'OpenKey', return_value=key()), \
181 with patch.object(wreg, 'OpenKey', return_value=key()), \
178 patch.object(wreg, 'QueryValueEx', return_value=[abspath(HOME_TEST_DIR)]):
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