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

Eduard Krein eduard.krein at linutronix.de
Wed Feb 7 16:31:07 CET 2024


Am Mittwoch, dem 07.02.2024 um 15:28 +0100 schrieb Benedikt Spranger:
> 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>
Reviewed-by: Eduard Krein <eduard.krein 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)

-- 
Eduard Krein
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 19; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy
can be found here): https://linutronix.de/legal/data-protection.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen |
Registergericht (Registration Court): Amtsgericht Freiburg i.Br.,HRB700
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas
Gleixner, Sharon Heck, Yulia Beck, Tiffany Silva




More information about the elbe-devel mailing list