[elbe-devel] [PATCH 4/9] elbepack: test_validate: gracefully handle network unavailibility

Thomas Weißschuh thomas.weissschuh at linutronix.de
Fri Mar 21 14:31:28 CET 2025


During Debian package builds the network may not be available.
However ELBE preprocess wants to inline apt repository keys by downloading them.

If no network is available, skip the test.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/tests/test_validate.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/elbepack/tests/test_validate.py b/elbepack/tests/test_validate.py
index 20c0238836e2601f7646358a3129365c001d03ad..5eb9f3a7c57e6864262dfd1723d75f4ea0fe7a93 100644
--- a/elbepack/tests/test_validate.py
+++ b/elbepack/tests/test_validate.py
@@ -4,6 +4,7 @@
 
 import itertools
 import os
+import socket
 
 import pytest
 
@@ -28,8 +29,22 @@ def _examples():
     ]
 
 
+def _root_cause(e):
+    while True:
+        if e.__context__ is None:
+            return e
+
+        e = e.__context__
+
+
 @pytest.mark.parametrize('f', itertools.chain(_test_cases(), _examples()))
 def test_validate(f, tmp_path):
     p = tmp_path / 'preprocessed.xml'
-    run_elbe_subcommand(['preprocess', '-o', p, f])
+    try:
+        run_elbe_subcommand(['preprocess', '-o', p, f])
+    except Exception as e:
+        root_cause = _root_cause(e)
+        if isinstance(root_cause, socket.gaierror) and root_cause.errno == socket.EAI_AGAIN:
+            pytest.skip('Network is unavailable')
+        raise
     run_elbe_subcommand(['validate', p])

-- 
2.48.1



More information about the elbe-devel mailing list