Changeset View
Changeset View
Standalone View
Standalone View
swh/core/tests/test_tarball.py
Show First 20 Lines • Show All 235 Lines • ▼ Show 20 Lines | def test_normalize_permissions(tmp_path): | ||||
tarball.normalize_permissions(str(tmp_path)) | tarball.normalize_permissions(str(tmp_path)) | ||||
for file in tmp_path.iterdir(): | for file in tmp_path.iterdir(): | ||||
if int(file.name) & 0o100: # original file was executable for its owner | if int(file.name) & 0o100: # original file was executable for its owner | ||||
assert file.stat().st_mode == 0o100755 | assert file.stat().st_mode == 0o100755 | ||||
else: | else: | ||||
assert file.stat().st_mode == 0o100644 | assert file.stat().st_mode == 0o100644 | ||||
def test_unpcompress_zip_imploded(tmp_path, datadir): | |||||
"""Unpack a zip archive with compression type 6 (implode), | |||||
not supported by python zipfile module. | |||||
""" | |||||
filename = "msk316src.zip" | |||||
anlambert: For the record, I did not manage to find a command enabling to generate a ZIP archive with… | |||||
zippath = os.path.join(datadir, "archives", filename) | |||||
assert os.path.exists(zippath) | |||||
extract_dir = os.path.join(tmp_path, filename) | |||||
os.makedirs(extract_dir, exist_ok=True) | |||||
output_directory = tarball.uncompress(zippath, extract_dir) | |||||
assert extract_dir == output_directory | |||||
assert len(os.listdir(extract_dir)) > 0 |
For the record, I did not manage to find a command enabling to generate a ZIP archive with compression type 6 on linux so I used such an an archive found in the wild instead as test data.