21
21
22
22
# Pretend all files are local, so UninstallPathSet accepts files in the tmpdir,
23
23
# outside the virtualenv
24
- def mock_is_local ( path : str ) -> bool :
24
+ def mock_permitted ( ups : UninstallPathSet , path : str ) -> bool :
25
25
return True
26
26
27
27
@@ -129,7 +129,7 @@ def in_tmpdir(paths: List[str]) -> List[str]:
129
129
130
130
class TestUninstallPathSet :
131
131
def test_add (self , tmpdir : Path , monkeypatch : pytest .MonkeyPatch ) -> None :
132
- monkeypatch .setattr (pip ._internal .req .req_uninstall , "is_local " , mock_is_local )
132
+ monkeypatch .setattr (pip ._internal .req .req_uninstall . UninstallPathSet , "_permitted " , mock_permitted )
133
133
# Fix case for windows tests
134
134
file_extant = os .path .normcase (os .path .join (tmpdir , "foo" ))
135
135
file_nonexistent = os .path .normcase (os .path .join (tmpdir , "nonexistent" ))
@@ -145,7 +145,7 @@ def test_add(self, tmpdir: Path, monkeypatch: pytest.MonkeyPatch) -> None:
145
145
assert ups ._paths == {file_extant }
146
146
147
147
def test_add_pth (self , tmp_path : Path , monkeypatch : pytest .MonkeyPatch ) -> None :
148
- monkeypatch .setattr (pip ._internal .req .req_uninstall , "is_local " , mock_is_local )
148
+ monkeypatch .setattr (pip ._internal .req .req_uninstall . UninstallPathSet , "_permitted " , mock_permitted )
149
149
# Fix case for windows tests
150
150
tmpdir = os .path .normcase (tmp_path )
151
151
on_windows = sys .platform == "win32"
@@ -175,7 +175,7 @@ def test_add_pth(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
175
175
176
176
@pytest .mark .skipif ("sys.platform == 'win32'" )
177
177
def test_add_symlink (self , tmpdir : Path , monkeypatch : pytest .MonkeyPatch ) -> None :
178
- monkeypatch .setattr (pip ._internal .req .req_uninstall , "is_local " , mock_is_local )
178
+ monkeypatch .setattr (pip ._internal .req .req_uninstall . UninstallPathSet , "_permitted " , mock_permitted )
179
179
f = os .path .join (tmpdir , "foo" )
180
180
with open (f , "w" ):
181
181
pass
@@ -187,7 +187,7 @@ def test_add_symlink(self, tmpdir: Path, monkeypatch: pytest.MonkeyPatch) -> Non
187
187
assert ups ._paths == {foo_link }
188
188
189
189
def test_compact_shorter_path (self , monkeypatch : pytest .MonkeyPatch ) -> None :
190
- monkeypatch .setattr (pip ._internal .req .req_uninstall , "is_local " , mock_is_local )
190
+ monkeypatch .setattr (pip ._internal .req .req_uninstall . UninstallPathSet , "_permitted " , mock_permitted )
191
191
monkeypatch .setattr ("os.path.exists" , lambda p : True )
192
192
# This deals with nt/posix path differences
193
193
short_path = os .path .normcase (
@@ -202,7 +202,7 @@ def test_compact_shorter_path(self, monkeypatch: pytest.MonkeyPatch) -> None:
202
202
def test_detect_symlink_dirs (
203
203
self , monkeypatch : pytest .MonkeyPatch , tmpdir : Path
204
204
) -> None :
205
- monkeypatch .setattr (pip ._internal .req .req_uninstall , "is_local " , mock_is_local )
205
+ monkeypatch .setattr (pip ._internal .req .req_uninstall . UninstallPathSet , "_permitted " , mock_permitted )
206
206
207
207
# construct 2 paths:
208
208
# tmpdir/dir/file
0 commit comments