~mvo/software-center/fix-index-update-terms-bug

« back to all changes in this revision

Viewing changes to tests/test_pep8.py

  • Committer: Michael Vogt
  • Date: 2012-08-15 10:03:27 UTC
  • mfrom: (3076.1.2 new-pep8)
  • Revision ID: michael.vogt@ubuntu.com-20120815100327-ajjy768f944i3qm3
merged  lp:~mvo/software-center/new-pep8  after review from kiwinote, many thanks

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import os
2
 
import pep8
 
2
import subprocess
3
3
import unittest
4
 
from collections import defaultdict
5
 
 
6
 
from tests.utils import (
7
 
    setup_test_env,
8
 
)
9
 
setup_test_env()
10
 
 
11
 
# Only test these two packages for now:
 
4
 
12
5
import softwarecenter
13
6
 
14
7
 
15
8
class PackagePep8TestCase(unittest.TestCase):
16
 
    maxDiff = None
17
 
    packages = [softwarecenter]
18
 
    exclude = []
19
 
 
20
 
    def message(self, text):
21
 
        self.errors.append(text)
22
 
 
23
 
    def setUp(self):
24
 
        self.errors = []
25
 
 
26
 
        class Options(object):
27
 
            exclude = self.exclude
28
 
            filename = ['*.py']
29
 
            testsuite = ''
30
 
            doctest = ''
31
 
            counters = defaultdict(int)
32
 
            messages = {}
33
 
            verbose = 0
34
 
            quiet = 0
35
 
            repeat = True
36
 
            show_source = False
37
 
            show_pep8 = False
38
 
            select = []
39
 
            ignore = []
40
 
            max_line_length = 79
41
 
        pep8.options = Options()
42
 
        pep8.message = self.message
43
 
        Options.physical_checks = pep8.find_checks('physical_line')
44
 
        Options.logical_checks = pep8.find_checks('logical_line')
45
9
 
46
10
    def test_all_code(self):
47
 
        for package in self.packages:
48
 
            pep8.input_dir(os.path.dirname(package.__file__))
49
 
        self.assertEqual([], self.errors)
 
11
        res = 0
 
12
        res += subprocess.call(
 
13
            ["pep8",
 
14
             "--repeat",
 
15
             os.path.dirname(softwarecenter.__file__)
 
16
             ])
 
17
        self.assertEqual(res, 0)
50
18
 
51
19
 
52
20
if __name__ == "__main__":