File tree 3 files changed +28
-3
lines changed
3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import sys
3
3
import platform
4
+ import pathlib
4
5
5
6
import pytest
6
7
import path
@@ -150,8 +151,18 @@ def suppress_path_mangle(monkeysession):
150
151
)
151
152
152
153
154
+ def _set_home (monkeypatch , path ):
155
+ var = 'USERPROFILE' if platform .system () == 'Windows' else 'HOME'
156
+ monkeypatch .setenv (var , str (path ))
157
+ return path
158
+
159
+
153
160
@pytest .fixture
154
161
def temp_home (tmp_path , monkeypatch ):
155
- var = 'USERPROFILE' if platform .system () == 'Windows' else 'HOME'
156
- monkeypatch .setenv (var , str (tmp_path ))
157
- return tmp_path
162
+ return _set_home (monkeypatch , tmp_path )
163
+
164
+
165
+ @pytest .fixture
166
+ def fake_home (fs , monkeypatch ):
167
+ home = fs .create_dir ('/fakehome' )
168
+ return _set_home (monkeypatch , pathlib .Path (home .path ))
Original file line number Diff line number Diff line change @@ -258,6 +258,19 @@ def test_find_config_files_disable(self, temp_home):
258
258
# make sure --no-user-cfg disables the user cfg file
259
259
assert len (all_files ) - 1 == len (files )
260
260
261
+ @pytest .mark .xfail (reason = "pypa/distutils#181" , strict = True )
262
+ @pytest .mark .skipif (
263
+ 'platform.system() == "Windows"' ,
264
+ reason = 'Windows does not honor chmod 000' ,
265
+ )
266
+ def test_find_config_files_permission_error (self , fake_home ):
267
+ """
268
+ Finding config files should not fail when directory is inaccessible.
269
+ """
270
+ fake_home .joinpath (pydistutils_cfg ).write_text ('' )
271
+ fake_home .chmod (0o000 )
272
+ Distribution ().find_config_files ()
273
+
261
274
262
275
@pytest .mark .usefixtures ('save_env' )
263
276
@pytest .mark .usefixtures ('save_argv' )
Original file line number Diff line number Diff line change 20
20
jaraco.text
21
21
path
22
22
docutils
23
+ pyfakefs
23
24
commands =
24
25
pytest {posargs}
25
26
setenv =
You can’t perform that action at this time.
0 commit comments