[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 18/31] tests/functional: add common zip_extract helper
From: |
Daniel P . Berrangé |
Subject: |
[PATCH v2 18/31] tests/functional: add common zip_extract helper |
Date: |
Wed, 11 Dec 2024 17:26:34 +0000 |
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(+)
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)
--
2.46.0
- [PATCH v2 12/31] tests/functional: switch over to using self.data_file(...), (continued)
- [PATCH v2 12/31] tests/functional: switch over to using self.data_file(...), Daniel P . Berrangé, 2024/12/11
- [PATCH v2 14/31] tests/functional: switch over to using self.socket_dir(...), Daniel P . Berrangé, 2024/12/11
- [PATCH v2 13/31] tests/functional: switch over to using self.scratch_file(), Daniel P . Berrangé, 2024/12/11
- [PATCH v2 15/31] tests/functional: remove redundant 'rmtree' call, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 16/31] tests/functional: move archive handling into new archive.py file, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 17/31] tests/functional: move uncompress handling into new uncompress.py file, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 18/31] tests/functional: add common zip_extract helper,
Daniel P . Berrangé <=
- [PATCH v2 19/31] tests/functional: add common deb_extract helper, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 20/31] tests/functional: let cpio_extract accept filenames, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 22/31] tests/functional: add 'archive_extract' to QemuBaseTest, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 21/31] tests/functional: add a generalized archive_extract, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 24/31] tests/functional: add a generalized uncompress helper, Daniel P . Berrangé, 2024/12/11