From 54bb2e188ab527104366d9b1723958bdb9b7759c Mon Sep 17 00:00:00 2001 From: BO ZHANG Date: Tue, 20 Sep 2022 18:08:18 +0800 Subject: [PATCH] added pycodestyle conformance --- pipelines/test_codestyle.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 pipelines/test_codestyle.py diff --git a/pipelines/test_codestyle.py b/pipelines/test_codestyle.py new file mode 100644 index 0000000..1a2fd4d --- /dev/null +++ b/pipelines/test_codestyle.py @@ -0,0 +1,22 @@ +import glob +import unittest +import pycodestyle + + +class TestCodeFormat(unittest.TestCase): + + def test_codestyle_conformance(self): + """Test that we conform to PEP-8.""" + style = pycodestyle.StyleGuide( + quiet=True, ignore=["E121", "E123", "E126", "E226", "E24", "E704", "W503", "W504", "E501"]) + result = style.check_files(glob.glob("./**/*.py")) + print("================ pycodestyle statistics ================") + if result.total_errors == 0: + print("Your code style is GREAT!") + else: + for line in result.get_statistics(): + print(line) + print("*** Please use the command below to check code yourself!!! ***") + print("pycodestyle ./**/*.py --ignore=E121,E123,E126,E226,E24,E704,W503,W504,E501") + print("========================================================") + self.assertEqual(result.total_errors, 0, "Found code style errors (and warnings).") -- GitLab