[elbe-devel] [PATCH 1/6] elbepack: test_flake8: migrate to subtests

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Mar 5 16:36:08 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_flake8.py | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/elbepack/tests/test_flake8.py b/elbepack/tests/test_flake8.py
index 1a81ef0137df..929b29a0a5b9 100644
--- a/elbepack/tests/test_flake8.py
+++ b/elbepack/tests/test_flake8.py
@@ -11,18 +11,17 @@ class TestPylint(ElbeTestCase):
     flake8_opts = ['--max-line-length=100',
                    '--show-source']
 
-    @staticmethod
-    def params():
+    def test_lint(self):
         files = system_out(f"find {pack_dir} -iname '*.py'").splitlines()
         files.append(elbe_exe)
-        return files
 
-    def test_lint(self):
-        err_out = None
-        try:
-            system(f"flake8 {' '.join(self.flake8_opts)} {self.param}")
-        except ElbeTestException as e:
-            err_out = e.out
+        for f in files:
+            with self.subTest(file=f):
+                err_out = None
+                try:
+                    system(f"flake8 {' '.join(self.flake8_opts)} {f}")
+                except ElbeTestException as e:
+                    err_out = e.out
 
-        if err_out is not None:
-            self.fail(err_out)
+                if err_out is not None:
+                    self.fail(err_out)

-- 
2.44.0



More information about the elbe-devel mailing list