Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): ensure only mocked system site is used #9941

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/repositories/test_installed_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,11 @@ def test_system_site_packages(
shutil.copytree(site_purelib / standard_dist_info, env.purelib / standard_dist_info)
orig_sys_path = env.sys_path
if with_system_site_packages:
# on some environments, there could be multiple system-site, filter out those and inject our test site
mocker.patch(
"poetry.utils.env.virtual_env.VirtualEnv.sys_path",
orig_sys_path[:-1] + [str(site_path)],
[p for p in orig_sys_path if p.startswith(str(tmp_path))]
+ [str(site_path)],
)
mocker.patch(
"poetry.utils.env.generic_env.GenericEnv.get_paths",
Expand All @@ -449,9 +451,10 @@ def test_system_site_packages(
installed_repository = InstalledRepository.load(env)

expected_system_site_packages = {"cleo"} if with_system_site_packages else set()
expected_packages = {"standard"} | expected_system_site_packages
if platform.system() == "FreeBSD":
expected_packages = {"standard"}
if platform.system() == "FreeBSD" and not with_system_site_packages:
expected_packages.add("sqlite3")
expected_packages |= expected_system_site_packages
assert {p.name for p in installed_repository.packages} == expected_packages
assert {
p.name for p in installed_repository.system_site_packages
Expand Down
Loading