def test_write_default_compress_type_is_from_init(self, buf, tmp_file): wf = WheelFile(buf, 'w', distname='_', version='0', compression=ZIP_BZIP2) wf.write(tmp_file) assert wf.infolist()[0].compress_type == ZIP_BZIP2
def test_recursive_writes_dont_misformat_record(self, tmp_path, buf): (tmp_path / "dir1").mkdir() written_dir = (tmp_path / "dir1" / "dir2") written_dir.mkdir() wf = WheelFile(buf, 'w', distname='mywheel', version='1') wf.write(tmp_path / "dir1", recursive=True) wf.close() wf = WheelFile(buf, 'r', distname='mywheel', version='1') assert str(written_dir) not in str(wf.record)
def test_passes_strict_timestamps_arg_to_zipfile(self, buf, tmp_file): wf = WheelFile(buf, mode='w', distname='_', version='0', strict_timestamps=False) # strict_timestamps will be propagated into ZipInfo objects created by # ZipFile. # Given very old timestamp, ZipInfo will set itself to 01-01-1980 os.utime(tmp_file, (10000000, 100000000)) wf.write(tmp_file, resolve=False) zinfo = wf.zipfile.getinfo(str(tmp_file).lstrip('/')) assert zinfo.date_time == (1980, 1, 1, 0, 0, 0)
def test_build_reproducibility(tmp_path): """Two wheels made from the same set of files should be the same""" (tmp_path / "package").mkdir() (tmp_path / "package" / "file").touch() wf1 = WheelFile(tmp_path / "1.whl", 'w', distname="mywheel", version='1') wf1.write(tmp_path / "package") wf1.close() wf2 = WheelFile(tmp_path / "2.whl", 'w', distname='mywheel', version='1') wf2.write(tmp_path / "package") wf2.close() with open(tmp_path / "1.whl", 'rb') as f: contents_wf1 = f.read() with open(tmp_path / "2.whl", 'rb') as f: contents_wf2 = f.read() assert contents_wf1 == contents_wf2
def test_write_default_compress_type_is_deflate(self, buf, tmp_file): wf = WheelFile(buf, 'w', distname='_', version='0') wf.write(tmp_file) assert wf.infolist()[0].compress_type == ZIP_DEFLATED
def test_write_default_compresslevel_is_from_init(self, buf, tmp_file): wf = WheelFile(buf, 'w', distname='_', version='0', compresslevel=9) wf.write(tmp_file) assert wf.infolist()[0]._compresslevel == 9
def test_write_default_compresslevel_is_none(self, buf, tmp_file): wf = WheelFile(buf, 'w', distname='_', version='0') wf.write(tmp_file) assert wf.infolist()[0]._compresslevel is None