test_codestyle.py 989 Bytes
Newer Older
BO ZHANG's avatar
BO ZHANG committed
1
2
3
4
5
6
7
8
9
10
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(
BO ZHANG's avatar
BO ZHANG committed
11
            quiet=True, ignore=["E121", "E123", "E126", "E226", "E24", "E704", "W503", "W504", "E501", "E722"])
BO ZHANG's avatar
BO ZHANG committed
12
13
14
15
16
17
18
19
        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!!! ***")
20
            print("pycodestyle ./**/*.py --ignore=E121,E123,E126,E226,E24,E704,W503,W504,E501,E722")
BO ZHANG's avatar
BO ZHANG committed
21
22
        print("========================================================")
        self.assertEqual(result.total_errors, 0, "Found code style errors (and warnings).")