Skip to content

Commit 75db610

Browse files
DefaultRyansbidoul
authored andcommitted
Mock _permitted instead of is_local
1 parent 82f1d14 commit 75db610

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/unit/test_req_uninstall.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
# Pretend all files are local, so UninstallPathSet accepts files in the tmpdir,
2323
# outside the virtualenv
24-
def mock_is_local(path: str) -> bool:
24+
def mock_permitted(ups: UninstallPathSet, path: str) -> bool:
2525
return True
2626

2727

@@ -129,7 +129,7 @@ def in_tmpdir(paths: List[str]) -> List[str]:
129129

130130
class TestUninstallPathSet:
131131
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)
133133
# Fix case for windows tests
134134
file_extant = os.path.normcase(os.path.join(tmpdir, "foo"))
135135
file_nonexistent = os.path.normcase(os.path.join(tmpdir, "nonexistent"))
@@ -145,7 +145,7 @@ def test_add(self, tmpdir: Path, monkeypatch: pytest.MonkeyPatch) -> None:
145145
assert ups._paths == {file_extant}
146146

147147
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)
149149
# Fix case for windows tests
150150
tmpdir = os.path.normcase(tmp_path)
151151
on_windows = sys.platform == "win32"
@@ -175,7 +175,7 @@ def test_add_pth(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
175175

176176
@pytest.mark.skipif("sys.platform == 'win32'")
177177
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)
179179
f = os.path.join(tmpdir, "foo")
180180
with open(f, "w"):
181181
pass
@@ -187,7 +187,7 @@ def test_add_symlink(self, tmpdir: Path, monkeypatch: pytest.MonkeyPatch) -> Non
187187
assert ups._paths == {foo_link}
188188

189189
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)
191191
monkeypatch.setattr("os.path.exists", lambda p: True)
192192
# This deals with nt/posix path differences
193193
short_path = os.path.normcase(
@@ -202,7 +202,7 @@ def test_compact_shorter_path(self, monkeypatch: pytest.MonkeyPatch) -> None:
202202
def test_detect_symlink_dirs(
203203
self, monkeypatch: pytest.MonkeyPatch, tmpdir: Path
204204
) -> 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)
206206

207207
# construct 2 paths:
208208
# tmpdir/dir/file

0 commit comments

Comments
 (0)