Merge lp:~mvo/software-center/new-pep8 into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3089
Proposed branch: lp:~mvo/software-center/new-pep8
Merge into: lp:software-center
Diff against target: 65 lines (+9/-41)
1 file modified
tests/test_pep8.py (+9/-41)
To merge this branch: bzr merge lp:~mvo/software-center/new-pep8
Reviewer Review Type Date Requested Status
Kiwinote Approve
Review via email: mp+118550@code.launchpad.net

Description of the change

This branch fixes the pep8 checker on quantal where the internal API has changed so that the current test_pep8.py will work even if there are pep8 errors.

The pep8 checks also got stricter I will do a separate branch for that that fixes them.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Is there anything that is blocking this branch from getting reviewed?

Revision history for this message
Kiwinote (kiwinote) wrote :

The proposed changes are fine - looking at the totality of the file we could simplify it slightly:
- afaics there is no reason why we should setup the test env - pep8 is a static test
- we can hardcode in the softwarecenter package for simplicity - the only thing we may change in the future is testing the whole source, we presumably won't go back to testing subpackages

A simplified test_pep8.py could eg be this:
===
import os.path
import softwarecenter
import subprocess
import unittest

class PackagePep8TestCase(unittest.TestCase):
    def test_all_code(self):
        res = subprocess.call(
                ["pep8",
                 "--repeat",
                 os.path.dirname(softwarecenter.__file__)
                 ])
        self.assertEqual(res, 0)

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

Feel free to merge either version, as they both fix the test itself.

review: Approve
Revision history for this message
Kiwinote (kiwinote) wrote :

(looks like launchpad stripped some newlines from that code snippet, making it non-pep8 compliant..)

lp:~mvo/software-center/new-pep8 updated
3078. By Michael Vogt

tests/test_pep8.py: simplify based on the feedback from kiwinote (many thanks)

Revision history for this message
Michael Vogt (mvo) wrote :

On Wed, Aug 15, 2012 at 09:39:20AM -0000, Kiwinote wrote:
> Review: Approve
>
> The proposed changes are fine - looking at the totality of the file we could simplify it slightly:
> - afaics there is no reason why we should setup the test env - pep8 is a static test
> - we can hardcode in the softwarecenter package for simplicity - the only thing we may change in the future is testing the whole source, we presumably won't go back to testing subpackages
[..]
> Feel free to merge either version, as they both fix the test itself.

Thanks for the feedback, this is good feedback, I simplified the code
now.

Cheers,
 Michael

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_pep8.py'
2--- tests/test_pep8.py 2012-06-20 10:20:01 +0000
3+++ tests/test_pep8.py 2012-08-15 10:02:24 +0000
4@@ -1,52 +1,20 @@
5 import os
6-import pep8
7+import subprocess
8 import unittest
9-from collections import defaultdict
10-
11-from tests.utils import (
12- setup_test_env,
13-)
14-setup_test_env()
15-
16-# Only test these two packages for now:
17+
18 import softwarecenter
19
20
21 class PackagePep8TestCase(unittest.TestCase):
22- maxDiff = None
23- packages = [softwarecenter]
24- exclude = []
25-
26- def message(self, text):
27- self.errors.append(text)
28-
29- def setUp(self):
30- self.errors = []
31-
32- class Options(object):
33- exclude = self.exclude
34- filename = ['*.py']
35- testsuite = ''
36- doctest = ''
37- counters = defaultdict(int)
38- messages = {}
39- verbose = 0
40- quiet = 0
41- repeat = True
42- show_source = False
43- show_pep8 = False
44- select = []
45- ignore = []
46- max_line_length = 79
47- pep8.options = Options()
48- pep8.message = self.message
49- Options.physical_checks = pep8.find_checks('physical_line')
50- Options.logical_checks = pep8.find_checks('logical_line')
51
52 def test_all_code(self):
53- for package in self.packages:
54- pep8.input_dir(os.path.dirname(package.__file__))
55- self.assertEqual([], self.errors)
56+ res = 0
57+ res += subprocess.call(
58+ ["pep8",
59+ "--repeat",
60+ os.path.dirname(softwarecenter.__file__)
61+ ])
62+ self.assertEqual(res, 0)
63
64
65 if __name__ == "__main__":

Subscribers

People subscribed via source and target branches