From 39c6ca7ea4c4ab101703fb72c0e17ed447e65e49 Mon Sep 17 00:00:00 2001 From: Andrey Semakin Date: Thu, 7 Nov 2019 12:15:59 +0500 Subject: [PATCH 1/2] Run flake8 as a test --- tests/test_flake8.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/test_flake8.py diff --git a/tests/test_flake8.py b/tests/test_flake8.py new file mode 100644 index 0000000..803e7bc --- /dev/null +++ b/tests/test_flake8.py @@ -0,0 +1,19 @@ +import pathlib +import unittest + +from flake8.api import legacy as flake8 + +test_modules = ['rsa', 'tests'] + + +class Flake8RunnerTest(unittest.TestCase): + def test_run_flake8(self): + proj_root = pathlib.Path(__file__).parent.parent + paths = [proj_root / dirname for dirname in test_modules] + + style_guide = flake8.get_style_guide() + report = style_guide.check_files(paths) + + errors = report.get_statistics('') + if errors: + self.fail('\n'.join(['Flake8 errors:'] + errors)) From 01e0896b34ff873c4686230a3e8a39e65d395ac2 Mon Sep 17 00:00:00 2001 From: Andrey Semakin Date: Thu, 7 Nov 2019 14:13:14 +0500 Subject: [PATCH 2/2] Convert Path object to str for Python 3.5 --- tests/test_flake8.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_flake8.py b/tests/test_flake8.py index 803e7bc..6035704 100644 --- a/tests/test_flake8.py +++ b/tests/test_flake8.py @@ -9,7 +9,7 @@ class Flake8RunnerTest(unittest.TestCase): def test_run_flake8(self): proj_root = pathlib.Path(__file__).parent.parent - paths = [proj_root / dirname for dirname in test_modules] + paths = [str(proj_root / dirname) for dirname in test_modules] style_guide = flake8.get_style_guide() report = style_guide.check_files(paths)