[elbe-devel] [PATCH 13/19] elbepack: tests: introduce helpers for xml testcases

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Mar 19 08:47:42 CET 2024


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

diff --git a/elbepack/tests/__init__.py b/elbepack/tests/__init__.py
index e69de29bb2d1..0db74029ec5c 100644
--- a/elbepack/tests/__init__.py
+++ b/elbepack/tests/__init__.py
@@ -0,0 +1,26 @@
+import pathlib
+
+import pytest
+
+
+def xml_test_files(prefix):
+    return [
+        file
+        for file
+        in pathlib.Path('tests').iterdir()
+        if file.name.startswith(prefix) and file.name.endswith('.xml')
+    ]
+
+
+def parametrize_xml_test_files(name, prefix):
+    """ Decorator to parametrize test functions for matching test XML files """
+
+    files = xml_test_files(prefix)
+
+    def wrapper(func):
+        return pytest.mark.parametrize(
+                name, files,
+                ids=[file.name for file in files]
+        )(func)
+
+    return wrapper

-- 
2.44.0



More information about the elbe-devel mailing list