Merge lp:~elopio/canonical-identity-provider/static-tests into lp:canonical-identity-provider/release

Proposed by Leo Arias
Status: Merged
Approved by: Natalia Bidart
Approved revision: no longer in the source branch.
Merged at revision: 544
Proposed branch: lp:~elopio/canonical-identity-provider/static-tests
Merge into: lp:canonical-identity-provider/release
Diff against target: 142 lines (+25/-88)
3 files modified
api/tests/test_static_code_analysis.py (+9/-9)
identityprovider/tests/unit/test_static_code_analysis.py (+15/-78)
requirements/testing.txt (+1/-1)
To merge this branch: bzr merge lp:~elopio/canonical-identity-provider/static-tests
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Review via email: mp+137925@code.launchpad.net

Commit message

Use the pep8 and pyflakes test cases from u1testutils.

Description of the change

Use the pep8 and pyflakes test cases from u1testutils.

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'api/tests/test_style.py' => 'api/tests/test_static_code_analysis.py'
2--- api/tests/test_style.py 2012-12-03 17:28:54 +0000
3+++ api/tests/test_static_code_analysis.py 2012-12-06 05:15:23 +0000
4@@ -1,14 +1,14 @@
5-from identityprovider.tests.unit.test_code_style import (
6- PackagePep8TestCase,
7- PyFlakesTestCase,
8+from u1testutils import (
9+ test_pep8_conformance,
10+ test_pyflakes_analysis,
11 )
12
13 import api
14
15
16-class ApiPep8TestCase(PackagePep8TestCase):
17- packages = [api]
18-
19-
20-class ApiPyFlakesTestCase(PyFlakesTestCase):
21- src_dir = 'api'
22+class ApiPep8TestCase(test_pep8_conformance.Pep8ConformanceTestCase):
23+ packages = [api]
24+
25+
26+class ApiPyFlakesTestCase(test_pyflakes_analysis.PyflakesAnalysisTestCase):
27+ packages = [api]
28
29=== renamed file 'identityprovider/tests/unit/test_code_style.py' => 'identityprovider/tests/unit/test_static_code_analysis.py'
30--- identityprovider/tests/unit/test_code_style.py 2012-10-12 21:23:31 +0000
31+++ identityprovider/tests/unit/test_static_code_analysis.py 2012-12-06 05:15:23 +0000
32@@ -1,82 +1,19 @@
33-import os
34-import pep8
35-
36-from collections import defaultdict
37-from cStringIO import StringIO
38-from unittest import TestCase
39+from u1testutils.static import (
40+ test_pep8_conformance,
41+ test_pyflakes_analysis,
42+)
43
44 import identityprovider
45
46-from mock import patch
47-from pyflakes.scripts.pyflakes import checkPath
48-
49-
50-class PackagePep8TestCase(TestCase):
51- maxDiff = None
52- packages = []
53+
54+class IdentityProviderPep8TestCase(
55+ test_pep8_conformance.Pep8ConformanceTestCase):
56+
57 exclude = ['migrations']
58-
59- def message(self, text):
60- self.errors.append(text)
61-
62- def setUp(self):
63- self.errors = {}
64- self.pep8style = pep8.StyleGuide(
65- counters=defaultdict(int),
66- doctest='',
67- exclude=self.exclude,
68- filename=['*.py'],
69- ignore=[],
70- messages=self.errors,
71- repeat=True,
72- select=[],
73- show_pep8=False,
74- show_source=False,
75- max_line_length=79,
76- quiet=0,
77- statistics=False,
78- testsuite='',
79- verbose=0,
80- )
81-
82- def test_all_code(self):
83- for package in self.packages:
84- self.pep8style.input_dir(os.path.dirname(package.__file__))
85- self.assertEqual(self.pep8style.options.report.total_errors, 0)
86-
87-
88-class IdentityProviderPep8TestCase(PackagePep8TestCase):
89-
90- packages = [identityprovider]
91-
92-
93-class PyFlakesTestCase(TestCase):
94-
95- src_dir = 'identityprovider'
96-
97- def test_pyflakes(self):
98- stdout = StringIO()
99- with patch('sys.stdout', stdout):
100- for dirpath, dirnames, filenames in os.walk(self.src_dir):
101- for filename in filenames:
102- if filename.endswith('.py'):
103- checkPath(os.path.join(dirpath, filename))
104-
105- with open('tools/pyflakes.txt') as data:
106- exclude = [tuple([part.strip() for part in
107- entry.split(':', 1)]) for entry in data
108- if entry.strip()]
109- errors = []
110- result = stdout.getvalue().splitlines()
111- for line in result:
112- found = False
113- for first, second in exclude:
114- if first and first in line:
115- if not second or second in line:
116- found = True
117- break
118-
119- if not found:
120- errors.append(line)
121- if errors:
122- self.fail('\n'.join(errors))
123+ packages = [identityprovider]
124+
125+
126+class PyFlakesTestCase(test_pyflakes_analysis.PyflakesAnalysisTestCase):
127+
128+ packages = [identityprovider]
129+ exclude_file = 'tools/pyflakes.txt'
130
131=== modified file 'requirements/testing.txt'
132--- requirements/testing.txt 2012-11-08 21:26:41 +0000
133+++ requirements/testing.txt 2012-12-06 05:15:23 +0000
134@@ -24,7 +24,7 @@
135 selenium==2.25.0
136 simplejson==2.3.0
137 twisted==11.1.0
138-u1-test-utils==0.1
139+u1-test-utils==0.2
140 unittest2==0.5.1
141 wadllib==1.3.1
142 wsgiref==0.1.2