Skip to content

Commit

Permalink
env: installing into MockEnv should not have side effects on anothe…
Browse files Browse the repository at this point in the history
…r env (#7141)

MockEnv should not use paths of SystemEnv for paths that may be written to
  • Loading branch information
radoering authored Dec 5, 2022
1 parent b2e2045 commit f594246
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,17 @@ def sys_path(self) -> list[str]:

return self._sys_path

@property
def paths(self) -> dict[str, str]:
if self._paths is None:
self._paths = self.get_paths()
self._paths["platlib"] = str(self._path / "platlib")
self._paths["purelib"] = str(self._path / "purelib")
self._paths["scripts"] = str(self._path / "scripts")
self._paths["data"] = str(self._path / "data")

return self._paths

def get_marker_env(self) -> dict[str, Any]:
if self._mock_marker_env is not None:
return self._mock_marker_env
Expand Down
10 changes: 0 additions & 10 deletions tests/masonry/builders/test_editable_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,6 @@ def test_builder_should_execute_build_scripts(
mocker: MockerFixture, extended_without_setup_poetry: Poetry, tmp_path: Path
):
env = MockEnv(path=tmp_path / "foo")
site_packages_dir = tmp_path / "site-packages"
site_packages_dir.mkdir(parents=True, exist_ok=True)
mocker.patch.object(
env,
"get_paths",
return_value={
"purelib": str(site_packages_dir),
"platlib": str(site_packages_dir),
},
)
mocker.patch(
"poetry.masonry.builders.editable.build_environment"
).return_value.__enter__.return_value = env
Expand Down

0 comments on commit f594246

Please sign in to comment.