Skip to content
Open
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
29 changes: 29 additions & 0 deletions test/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,35 @@ def test_cache_path(self, env_var):
with env_var("FOO", "foo"):
assert cache_path(mock_zip, '$FOO', uuid) == Path("foo", f"test_{uuid}")

@pytest.mark.parametrize("suffix", ("", ".pyz"))
def test_versioned_archives_have_distinct_extraction_paths(self, tmp_path, suffix):
# Regression for #203: using stem drops version components and build IDs.
root = tmp_path / "cache"
targets = []
for version, build_id in (("1.2.3", "build-one"), ("1.2.5", "build-two")):
filename = f"app-{version}{suffix}"
archive_path = tmp_path / filename
with ZipFile(archive_path, "w") as archive:
archive.writestr("site-packages/version.txt", version)

with ZipFile(archive_path) as archive:
target = cache_path(archive, str(root), build_id)
assert target.name == f"{filename}_{build_id}"
with mock.patch.object(archive, "extract", wraps=archive.extract) as extract:
extract_site_packages(archive, target)
extract.assert_called_once_with(
"site-packages/version.txt", root / f"{target.name}.tmp"
)
targets.append(target)

assert targets[0] != targets[1]
assert {path.name for path in root.iterdir()} == {
targets[0].name, targets[1].name,
f".{targets[0].name}_lock", f".{targets[1].name}_lock",
}
for target, version in zip(targets, ("1.2.3", "1.2.5")):
assert (target / "site-packages/version.txt").read_text() == version

def test_first_sitedir_index(self):
with mock.patch.object(sys, "path", ["site-packages", "dir", "dir", "dir"]):
assert get_first_sitedir_index() == 0
Expand Down