~kelemeng/software-center/bug953812

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import pep8
import unittest
from collections import defaultdict

from testutils import setup_test_env
setup_test_env()

# Only test these two packages for now:
import softwarecenter.db.pkginfo_impl
import softwarecenter.ui.gtk3.widgets
import softwarecenter.ui.qml

class PackagePep8TestCase(unittest.TestCase):
    maxDiff = None
    packages = [softwarecenter.ui.qml,
                softwarecenter.ui.gtk3.widgets,
                softwarecenter.db.pkginfo_impl]
    exclude = ['buttons.py', 'apptreeview.py', 'actionbar.py']

    def message(self, text):
        self.errors.append(text)

    def setUp(self):
        self.errors = []

        class Options(object):
            exclude = self.exclude
            filename = ['*.py']
            testsuite = ''
            doctest = ''
            counters = defaultdict(int)
            messages = {}
            verbose = 0
            quiet = 0
            repeat = True
            show_source = False
            show_pep8 = False
            select = []
            ignore = []
        pep8.options = Options()
        pep8.message = self.message
        Options.physical_checks = pep8.find_checks('physical_line')
        Options.logical_checks = pep8.find_checks('logical_line')

    def test_all_code(self):
        for package in self.packages:
            pep8.input_dir(os.path.dirname(package.__file__))
        self.assertEqual([], self.errors)

if __name__ == "__main__":
    unittest.main()