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
=== renamed file 'api/tests/test_style.py' => 'api/tests/test_static_code_analysis.py'
--- api/tests/test_style.py 2012-12-03 17:28:54 +0000
+++ api/tests/test_static_code_analysis.py 2012-12-06 05:15:23 +0000
@@ -1,14 +1,14 @@
1from identityprovider.tests.unit.test_code_style import (1from u1testutils import (
2 PackagePep8TestCase,2 test_pep8_conformance,
3 PyFlakesTestCase,3 test_pyflakes_analysis,
4)4)
55
6import api6import api
77
88
9class ApiPep8TestCase(PackagePep8TestCase):9class ApiPep8TestCase(test_pep8_conformance.Pep8ConformanceTestCase):
10 packages = [api]10 packages = [api]
1111
1212
13class ApiPyFlakesTestCase(PyFlakesTestCase):13class ApiPyFlakesTestCase(test_pyflakes_analysis.PyflakesAnalysisTestCase):
14 src_dir = 'api'14 packages = [api]
1515
=== renamed file 'identityprovider/tests/unit/test_code_style.py' => 'identityprovider/tests/unit/test_static_code_analysis.py'
--- identityprovider/tests/unit/test_code_style.py 2012-10-12 21:23:31 +0000
+++ identityprovider/tests/unit/test_static_code_analysis.py 2012-12-06 05:15:23 +0000
@@ -1,82 +1,19 @@
1import os1from u1testutils.static import (
2import pep82 test_pep8_conformance,
33 test_pyflakes_analysis,
4from collections import defaultdict4)
5from cStringIO import StringIO
6from unittest import TestCase
75
8import identityprovider6import identityprovider
97
10from mock import patch8
11from pyflakes.scripts.pyflakes import checkPath9class IdentityProviderPep8TestCase(
1210 test_pep8_conformance.Pep8ConformanceTestCase):
1311
14class PackagePep8TestCase(TestCase):
15 maxDiff = None
16 packages = []
17 exclude = ['migrations']12 exclude = ['migrations']
1813 packages = [identityprovider]
19 def message(self, text):14
20 self.errors.append(text)15
2116class PyFlakesTestCase(test_pyflakes_analysis.PyflakesAnalysisTestCase):
22 def setUp(self):17
23 self.errors = {}18 packages = [identityprovider]
24 self.pep8style = pep8.StyleGuide(19 exclude_file = 'tools/pyflakes.txt'
25 counters=defaultdict(int),
26 doctest='',
27 exclude=self.exclude,
28 filename=['*.py'],
29 ignore=[],
30 messages=self.errors,
31 repeat=True,
32 select=[],
33 show_pep8=False,
34 show_source=False,
35 max_line_length=79,
36 quiet=0,
37 statistics=False,
38 testsuite='',
39 verbose=0,
40 )
41
42 def test_all_code(self):
43 for package in self.packages:
44 self.pep8style.input_dir(os.path.dirname(package.__file__))
45 self.assertEqual(self.pep8style.options.report.total_errors, 0)
46
47
48class IdentityProviderPep8TestCase(PackagePep8TestCase):
49
50 packages = [identityprovider]
51
52
53class PyFlakesTestCase(TestCase):
54
55 src_dir = 'identityprovider'
56
57 def test_pyflakes(self):
58 stdout = StringIO()
59 with patch('sys.stdout', stdout):
60 for dirpath, dirnames, filenames in os.walk(self.src_dir):
61 for filename in filenames:
62 if filename.endswith('.py'):
63 checkPath(os.path.join(dirpath, filename))
64
65 with open('tools/pyflakes.txt') as data:
66 exclude = [tuple([part.strip() for part in
67 entry.split(':', 1)]) for entry in data
68 if entry.strip()]
69 errors = []
70 result = stdout.getvalue().splitlines()
71 for line in result:
72 found = False
73 for first, second in exclude:
74 if first and first in line:
75 if not second or second in line:
76 found = True
77 break
78
79 if not found:
80 errors.append(line)
81 if errors:
82 self.fail('\n'.join(errors))
8320
=== modified file 'requirements/testing.txt'
--- requirements/testing.txt 2012-11-08 21:26:41 +0000
+++ requirements/testing.txt 2012-12-06 05:15:23 +0000
@@ -24,7 +24,7 @@
24selenium==2.25.024selenium==2.25.0
25simplejson==2.3.025simplejson==2.3.0
26twisted==11.1.026twisted==11.1.0
27u1-test-utils==0.127u1-test-utils==0.2
28unittest2==0.5.128unittest2==0.5.1
29wadllib==1.3.129wadllib==1.3.1
30wsgiref==0.1.230wsgiref==0.1.2