[elbe-devel] [PATCH 2/6] elbepack: test_preproc: migrate to subtests

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Mar 5 16:36:09 CET 2024


The custom test-parameterization is not compatible with pytest.
As pytest is more featureful than our own test runner prepare for
switching over.

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

diff --git a/elbepack/tests/test_preproc.py b/elbepack/tests/test_preproc.py
index 0dfb44c51714..bde60509b9ea 100644
--- a/elbepack/tests/test_preproc.py
+++ b/elbepack/tests/test_preproc.py
@@ -10,14 +10,15 @@ from elbepack.directories import elbe_dir, elbe_exe
 
 
 class TestPreproc(ElbeTestCase):
-    params = [os.path.join(elbe_dir, 'tests', fname)
-              for fname
-              in os.listdir(os.path.join(elbe_dir, 'tests'))
-              if fname.startswith('preproc') and fname.endswith('.xml')]
-
     def test_preproc(self):
-        try:
-            system(f'{sys.executable} {elbe_exe} preprocess "{self.param}"')
-        except ElbeTestException as e:
-            self.stdout = e.out
-            raise
+        for param in [os.path.join(elbe_dir, 'tests', fname)
+                      for fname
+                      in os.listdir(os.path.join(elbe_dir, 'tests'))
+                      if fname.startswith('preproc') and fname.endswith('.xml')]:
+
+            with self.subTest(file=param):
+                try:
+                    system(f'{sys.executable} {elbe_exe} preprocess "{param}"')
+                except ElbeTestException as e:
+                    self.stdout = e.out
+                    raise

-- 
2.44.0



More information about the elbe-devel mailing list