[elbe-devel] [PATCH 2/2] test_elbevalidate: gracefully handle missing guestfs module
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Wed Jun 12 10:22:15 CEST 2024
The guestfs module shouldn't be a hard dependency on running the tests.
Handle it gracefully by marking the test as skipped if it is missing.
Reported-by: Eduard Krein <eduard.krein at linutronix.de>
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
test/test_elbevalidate.py | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/test/test_elbevalidate.py b/test/test_elbevalidate.py
index f34eca5df01d..de3d5bc081c6 100644
--- a/test/test_elbevalidate.py
+++ b/test/test_elbevalidate.py
@@ -1,10 +1,22 @@
+import importlib
import pathlib
import struct
import subprocess
import tempfile
import textwrap
-import elbevalidate
+import pytest
+
+
+ at pytest.fixture
+def elbevalidate():
+ try:
+ return importlib.import_module('elbevalidate', package=__name__)
+ except ModuleNotFoundError as e:
+ if e.name == 'guestfs':
+ pytest.skip(f'module {e.name} not found')
+ else:
+ raise
def _round_to(n, g):
@@ -61,7 +73,7 @@ def _make_partition(path):
return pathlib.Path(t.name).read_bytes()
-def test_elbevalidate(tmp_path):
+def test_elbevalidate(elbevalidate, tmp_path):
part1_dir = tmp_path / 'part1'
part1_dir.mkdir()
--
2.45.2
More information about the elbe-devel
mailing list