def test_on_bufs_x_mode_behaves_same_as_w(self): f1, f2 = BytesIO(), BytesIO() wf1 = WheelFile(f1, 'w', distname='_', version='0') wf1.close() wf2 = WheelFile(f2, 'w', distname='_', version='0') wf2.close() assert f1.getvalue() == f2.getvalue()
def wf(self, buf): wf = WheelFile(buf, 'w', distname='_', version='0', compression=ZIP_STORED, compresslevel=1) yield wf wf.close()
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_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 wheelfile(self, buf): wf = WheelFile(buf, 'w', distname=self.distname, version=self.version) wf.metadata.requires_dists = [self.long_requirement] wf.close() return wf
def wheelfile(self, buf): wf = WheelFile(buf, 'w', distname=self.distname, version=self.version) wf.close() return wf
def wheelfile(self, buf): wf = WheelFile(buf, 'w', distname=self.distname, version=self.version) wf.entry_points.add(EntryPoint("foo", "bar", "baz")) wf.close() return wf
def test_can_work_on_in_memory_bufs(buf): wf = WheelFile(buf, 'w', distname='_', version='0') wf.close() assert buf.tell() != 0
def test_close_in_read_mode_does_not_try_to_write(self, empty_wheel): wf = WheelFile(empty_wheel.filename) try: wf.close() except ValueError: # ValueError: write() requires mode 'w', 'x', or 'a' pytest.fail("Attempt to write on close() in read mode")
def wf(buf): wf = WheelFile(buf, 'w', distname='_', version='0') yield wf wf.close()