diff options
author | Ryan Shepherd <ryansh@microsoft.com> | 2023-03-20 10:43:33 -0700 |
---|---|---|
committer | Stéphane Bidoul <stephane.bidoul@gmail.com> | 2023-04-10 16:45:34 +0200 |
commit | 75db61099d470180cfba3a8f76bc73d26a341719 (patch) | |
tree | 1b09841db610e2b1a30e88af0e92884521c16c2d | |
parent | 82f1d14772b557a705dae7d49192b8c5b92bf05a (diff) | |
download | pip-75db61099d470180cfba3a8f76bc73d26a341719.tar.gz |
Mock _permitted instead of is_local
-rw-r--r-- | tests/unit/test_req_uninstall.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/unit/test_req_uninstall.py b/tests/unit/test_req_uninstall.py index 4d99acfd3..f990edc2b 100644 --- a/tests/unit/test_req_uninstall.py +++ b/tests/unit/test_req_uninstall.py @@ -21,7 +21,7 @@ from tests.lib import create_file # Pretend all files are local, so UninstallPathSet accepts files in the tmpdir, # outside the virtualenv -def mock_is_local(path: str) -> bool: +def mock_permitted(ups: UninstallPathSet, path: str) -> bool: return True @@ -129,7 +129,7 @@ def test_compressed_listing(tmpdir: Path) -> None: class TestUninstallPathSet: def test_add(self, tmpdir: Path, monkeypatch: pytest.MonkeyPatch) -> None: - monkeypatch.setattr(pip._internal.req.req_uninstall, "is_local", mock_is_local) + monkeypatch.setattr(pip._internal.req.req_uninstall.UninstallPathSet, "_permitted", mock_permitted) # Fix case for windows tests file_extant = os.path.normcase(os.path.join(tmpdir, "foo")) file_nonexistent = os.path.normcase(os.path.join(tmpdir, "nonexistent")) @@ -145,7 +145,7 @@ class TestUninstallPathSet: assert ups._paths == {file_extant} def test_add_pth(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: - monkeypatch.setattr(pip._internal.req.req_uninstall, "is_local", mock_is_local) + monkeypatch.setattr(pip._internal.req.req_uninstall.UninstallPathSet, "_permitted", mock_permitted) # Fix case for windows tests tmpdir = os.path.normcase(tmp_path) on_windows = sys.platform == "win32" @@ -175,7 +175,7 @@ class TestUninstallPathSet: @pytest.mark.skipif("sys.platform == 'win32'") def test_add_symlink(self, tmpdir: Path, monkeypatch: pytest.MonkeyPatch) -> None: - monkeypatch.setattr(pip._internal.req.req_uninstall, "is_local", mock_is_local) + monkeypatch.setattr(pip._internal.req.req_uninstall.UninstallPathSet, "_permitted", mock_permitted) f = os.path.join(tmpdir, "foo") with open(f, "w"): pass @@ -187,7 +187,7 @@ class TestUninstallPathSet: assert ups._paths == {foo_link} def test_compact_shorter_path(self, monkeypatch: pytest.MonkeyPatch) -> None: - monkeypatch.setattr(pip._internal.req.req_uninstall, "is_local", mock_is_local) + monkeypatch.setattr(pip._internal.req.req_uninstall.UninstallPathSet, "_permitted", mock_permitted) monkeypatch.setattr("os.path.exists", lambda p: True) # This deals with nt/posix path differences short_path = os.path.normcase( @@ -202,7 +202,7 @@ class TestUninstallPathSet: def test_detect_symlink_dirs( self, monkeypatch: pytest.MonkeyPatch, tmpdir: Path ) -> None: - monkeypatch.setattr(pip._internal.req.req_uninstall, "is_local", mock_is_local) + monkeypatch.setattr(pip._internal.req.req_uninstall.UninstallPathSet, "_permitted", mock_permitted) # construct 2 paths: # tmpdir/dir/file |