Message ID | 20241211172648.2893097-19-berrange@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | tests/functional: various improvements wrt assets/scratch files | expand |
On 11/12/2024 18.26, Daniel P. Berrangé wrote: > This mirrors the existing archive_extract and cpio_extract helpers > > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> > --- > tests/functional/qemu_test/archive.py | 8 ++++++++ > 1 file changed, 8 insertions(+) Reviewed-by: Thomas Huth <thuth@redhat.com>
diff --git a/tests/functional/qemu_test/archive.py b/tests/functional/qemu_test/archive.py index 9872f08d23..06b66701c0 100644 --- a/tests/functional/qemu_test/archive.py +++ b/tests/functional/qemu_test/archive.py @@ -10,6 +10,7 @@ import os import subprocess import tarfile +import zipfile def tar_extract(archive, dest_dir, member=None): @@ -29,3 +30,10 @@ def cpio_extract(cpio_handle, output_path): input=cpio_handle.read(), stderr=subprocess.DEVNULL) os.chdir(cwd) + +def zip_extract(archive, dest_dir, member=None): + with zipfile.ZipFile(archive, 'r') as zf: + if member: + zf.extract(member=member, path=dest_dir) + else: + zf.extractall(path=dest_dir)
This mirrors the existing archive_extract and cpio_extract helpers Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- tests/functional/qemu_test/archive.py | 8 ++++++++ 1 file changed, 8 insertions(+)