[elbe-devel] [PATCH 27/37] Add flake8 test

Benedikt Spranger b.spranger at linutronix.de
Wed Feb 7 15:28:54 CET 2024


flake8 is a popular tool for managing PEP8 compliance for code.
Use it to check E.L.B.E. for PEP8 compliance.

Signed-off-by: Benedikt Spranger <b.spranger at linutronix.de>
---
 elbepack/tests/test_flake8.py | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 elbepack/tests/test_flake8.py

diff --git a/elbepack/tests/test_flake8.py b/elbepack/tests/test_flake8.py
new file mode 100644
index 00000000..0b95cb53
--- /dev/null
+++ b/elbepack/tests/test_flake8.py
@@ -0,0 +1,34 @@
+# ELBE - Debian Based Embedded Rootfilesystem Builder
+# SPDX-License-Identifier: GPL-3.0-or-later
+# SPDX-FileCopyrightText: 2020 Linutronix GmbH
+
+import os
+
+from elbepack.commands.test import ElbeTestCase, system, ElbeTestException
+from elbepack.shellhelper import system_out
+from elbepack.directories import pack_dir, elbe_exe
+
+
+class TestPylint(ElbeTestCase):
+    global elbe_dir      # pylint: disable=global-statement
+
+    elbe_dir = os.path.join(os.path.dirname(__file__), "../..")
+
+    flake8_opts = ["--max-line-length=100",
+                   "--show-source"]
+
+    @staticmethod
+    def params():
+        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
+
+        if err_out is not None:
+            self.fail(err_out)
-- 
2.43.0



More information about the elbe-devel mailing list