Merge lp:~ev/uci-engine/pyflakes-the-world into lp:uci-engine

Proposed by Evan
Status: Superseded
Proposed branch: lp:~ev/uci-engine/pyflakes-the-world
Merge into: lp:uci-engine
Diff against target: 880 lines (+67/-558)
30 files modified
branch-source-builder/bsbuilder/tests/test_style.py (+0/-28)
britney_proxy/bin/uci-britney-post-deploy (+1/-1)
britney_proxy/britney/tests/test_style.py (+0/-28)
ci-utils/ci_utils/tests/test_style.py (+0/-28)
gatekeeper/gatekeeper/tests/test_style.py (+0/-28)
image-builder/imagebuilder/tests/test_style.py (+0/-28)
juju-deployer/test_style.py (+0/-32)
lander/lander/tests/test_style.py (+0/-42)
ppa-creator/ppacreator/tests/test_style.py (+0/-28)
publisher/publisher/tests/test_style.py (+0/-42)
test_runner/tstrun/tests/test_style.py (+0/-28)
testing/run_tests.py (+2/-2)
testing/styles.py (+0/-72)
testing/test_style.py (+0/-28)
tests/integration/test_britney.py (+1/-1)
tests/integration/test_bsbuilder.py (+1/-1)
tests/integration/test_image_builder.py (+1/-1)
tests/integration/test_ppacreator.py (+1/-1)
tests/integration/test_publisher.py (+1/-1)
tests/integration/test_rabbit.py (+1/-1)
tests/integration/test_test_runner.py (+1/-1)
tests/integration/test_ticket_system.py (+1/-1)
tests/integration/test_validator.py (+1/-1)
tests/integration/test_webui.py (+1/-1)
tests/project/test_static.py (+10/-30)
tests/project/test_syntax.py (+44/-0)
ticket_system/project/tests.py (+0/-15)
ticket_system/ticket/tests/test_style.py (+0/-38)
validator/validator/tests/test_style.py (+0/-42)
webui/status/tests.py (+0/-8)
To merge this branch: bzr merge lp:~ev/uci-engine/pyflakes-the-world
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+242818@code.launchpad.net

This proposal has been superseded by a proposal from 2014-11-25.

Commit message

Rather than opt-in to PEP8 and pyflakes testing module-by-module, cover all python code, non-module code included, with an explicit opt-out.

Description of the change

Another branch I worked on while flying to Austin. Rather than opt-in to PEP8 and pyflakes testing module-by-module, cover all python code, non-module code included, with an explicit opt-out.

Time and time again we failed to test for pep8 or pyflakes because we forgot to drop a test_style or find the right directory in the test_style code.

I expect this MP to be controversial, but I no of no other way to ensure we don't miss files with pyflakes in the future.

To post a comment you must log in.
lp:~ev/uci-engine/pyflakes-the-world updated
910. By Evan

Missing reference to test_style.

Revision history for this message
Paul Larson (pwlars) wrote :

no controversy as far as I'm concerned. Any python we have that doesn't pass pyflakes should need a good reason to opt out, otherwise the fixes are almost always trivial. The +67/-558 diffstat makes it clear that this is far more efficient than reproducing the pyflakes test all over the place too.

A couple of minor style things, but otherwise a huge +1 from me

review: Approve
lp:~ev/uci-engine/pyflakes-the-world updated
911. By Evan

Fix up test references in README.

912. By Evan

Use .format

913. By Evan

Missed one example fix.

914. By Evan

Make the error text part of the exception so it's only printed at the end. Thanks for the tip, Vincent.

915. By Evan

Unneeded import.

916. By Evan

Add great explanation of django's test star imports from Vincent.

917. By Evan

Refer to the previous commit in the syntax tests.

918. By Canonical CI Engineering

Adjust comment to make note of the fact that we need to resync with cupstream2distro trunk in a follow up MP.

Unmerged revisions

918. By Canonical CI Engineering

Adjust comment to make note of the fact that we need to resync with cupstream2distro trunk in a follow up MP.

917. By Evan

Refer to the previous commit in the syntax tests.

916. By Evan

Add great explanation of django's test star imports from Vincent.

915. By Evan

Unneeded import.

914. By Evan

Make the error text part of the exception so it's only printed at the end. Thanks for the tip, Vincent.

913. By Evan

Missed one example fix.

912. By Evan

Use .format

911. By Evan

Fix up test references in README.

910. By Evan

Missing reference to test_style.

909. By Evan

Remove more style tests.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'branch-source-builder/bsbuilder/tests/test_style.py'
2--- branch-source-builder/bsbuilder/tests/test_style.py 2014-02-15 12:06:40 +0000
3+++ branch-source-builder/bsbuilder/tests/test_style.py 1970-01-01 00:00:00 +0000
4@@ -1,28 +0,0 @@
5-# Ubuntu CI Engine
6-# Copyright 2014 Canonical Ltd.
7-
8-# This program is free software: you can redistribute it and/or modify it
9-# under the terms of the GNU Affero General Public License version 3, as
10-# published by the Free Software Foundation.
11-
12-# This program is distributed in the hope that it will be useful, but
13-# WITHOUT ANY WARRANTY; without even the implied warranties of
14-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15-# PURPOSE. See the GNU Affero General Public License for more details.
16-
17-# You should have received a copy of the GNU Affero General Public License
18-# along with this program. If not, see <http://www.gnu.org/licenses/>.
19-
20-from ucitests import styles
21-
22-import bsbuilder
23-
24-
25-class TestPep8(styles.TestPep8):
26-
27- packages = [bsbuilder]
28-
29-
30-class TestPyflakes(styles.TestPyflakes):
31-
32- packages = [bsbuilder]
33
34=== modified file 'britney_proxy/bin/uci-britney-post-deploy'
35--- britney_proxy/bin/uci-britney-post-deploy 2014-10-15 09:25:55 +0000
36+++ britney_proxy/bin/uci-britney-post-deploy 2014-11-25 17:16:49 +0000
37@@ -29,7 +29,7 @@
38 sys.path.insert(0, BRANCH_ROOT)
39
40
41-from tests import deployers
42+from testing import deployers
43
44
45 def main(args):
46
47=== removed file 'britney_proxy/britney/tests/test_style.py'
48--- britney_proxy/britney/tests/test_style.py 2014-09-22 13:21:25 +0000
49+++ britney_proxy/britney/tests/test_style.py 1970-01-01 00:00:00 +0000
50@@ -1,28 +0,0 @@
51-# Ubuntu CI Engine
52-# Copyright 2014 Canonical Ltd.
53-
54-# This program is free software: you can redistribute it and/or modify it
55-# under the terms of the GNU Affero General Public License version 3, as
56-# published by the Free Software Foundation.
57-
58-# This program is distributed in the hope that it will be useful, but
59-# WITHOUT ANY WARRANTY; without even the implied warranties of
60-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
61-# PURPOSE. See the GNU Affero General Public License for more details.
62-
63-# You should have received a copy of the GNU Affero General Public License
64-# along with this program. If not, see <http://www.gnu.org/licenses/>.
65-
66-from ucitests import styles
67-
68-import britney
69-
70-
71-class TestPep8(styles.TestPep8):
72-
73- packages = [britney]
74-
75-
76-class TestPyflakes(styles.TestPyflakes):
77-
78- packages = [britney]
79
80=== removed file 'ci-utils/ci_utils/tests/test_style.py'
81--- ci-utils/ci_utils/tests/test_style.py 2014-02-15 12:06:40 +0000
82+++ ci-utils/ci_utils/tests/test_style.py 1970-01-01 00:00:00 +0000
83@@ -1,28 +0,0 @@
84-# Ubuntu CI Engine
85-# Copyright 2014 Canonical Ltd.
86-
87-# This program is free software: you can redistribute it and/or modify it
88-# under the terms of the GNU Affero General Public License version 3, as
89-# published by the Free Software Foundation.
90-
91-# This program is distributed in the hope that it will be useful, but
92-# WITHOUT ANY WARRANTY; without even the implied warranties of
93-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
94-# PURPOSE. See the GNU Affero General Public License for more details.
95-
96-# You should have received a copy of the GNU Affero General Public License
97-# along with this program. If not, see <http://www.gnu.org/licenses/>.
98-
99-from ucitests import styles
100-
101-import ci_utils
102-
103-
104-class TestPep8(styles.TestPep8):
105-
106- packages = [ci_utils]
107-
108-
109-class TestPyflakes(styles.TestPyflakes):
110-
111- packages = [ci_utils]
112
113=== removed file 'gatekeeper/gatekeeper/tests/test_style.py'
114--- gatekeeper/gatekeeper/tests/test_style.py 2014-04-25 17:06:52 +0000
115+++ gatekeeper/gatekeeper/tests/test_style.py 1970-01-01 00:00:00 +0000
116@@ -1,28 +0,0 @@
117-# Ubuntu CI Engine
118-# Copyright 2014 Canonical Ltd.
119-
120-# This program is free software: you can redistribute it and/or modify it
121-# under the terms of the GNU Affero General Public License version 3, as
122-# published by the Free Software Foundation.
123-
124-# This program is distributed in the hope that it will be useful, but
125-# WITHOUT ANY WARRANTY; without even the implied warranties of
126-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
127-# PURPOSE. See the GNU Affero General Public License for more details.
128-
129-# You should have received a copy of the GNU Affero General Public License
130-# along with this program. If not, see <http://www.gnu.org/licenses/>.
131-
132-from ucitests import styles
133-
134-import gatekeeper
135-
136-
137-class TestPep8(styles.TestPep8):
138-
139- packages = [gatekeeper]
140-
141-
142-class TestPyflakes(styles.TestPyflakes):
143-
144- packages = [gatekeeper]
145
146=== removed file 'image-builder/imagebuilder/tests/test_style.py'
147--- image-builder/imagebuilder/tests/test_style.py 2014-02-15 12:06:40 +0000
148+++ image-builder/imagebuilder/tests/test_style.py 1970-01-01 00:00:00 +0000
149@@ -1,28 +0,0 @@
150-# Ubuntu CI Engine
151-# Copyright 2014 Canonical Ltd.
152-
153-# This program is free software: you can redistribute it and/or modify it
154-# under the terms of the GNU Affero General Public License version 3, as
155-# published by the Free Software Foundation.
156-
157-# This program is distributed in the hope that it will be useful, but
158-# WITHOUT ANY WARRANTY; without even the implied warranties of
159-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
160-# PURPOSE. See the GNU Affero General Public License for more details.
161-
162-# You should have received a copy of the GNU Affero General Public License
163-# along with this program. If not, see <http://www.gnu.org/licenses/>.
164-
165-from ucitests import styles
166-
167-import imagebuilder
168-
169-
170-class TestPep8(styles.TestPep8):
171-
172- packages = [imagebuilder]
173-
174-
175-class TestPyflakes(styles.TestPyflakes):
176-
177- packages = [imagebuilder]
178
179=== removed file 'juju-deployer/test_style.py'
180--- juju-deployer/test_style.py 2014-06-18 13:15:24 +0000
181+++ juju-deployer/test_style.py 1970-01-01 00:00:00 +0000
182@@ -1,32 +0,0 @@
183-# Ubuntu CI Engine
184-# Copyright 2014 Canonical Ltd.
185-
186-# This program is free software: you can redistribute it and/or modify it
187-# under the terms of the GNU Affero General Public License version 3, as
188-# published by the Free Software Foundation.
189-
190-# This program is distributed in the hope that it will be useful, but
191-# WITHOUT ANY WARRANTY; without even the implied warranties of
192-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
193-# PURPOSE. See the GNU Affero General Public License for more details.
194-
195-# You should have received a copy of the GNU Affero General Public License
196-# along with this program. If not, see <http://www.gnu.org/licenses/>.
197-
198-import os
199-
200-
201-HERE = os.path.abspath(os.path.dirname(__file__))
202-
203-
204-from testing import styles
205-
206-
207-class TestPep8(styles.TestPep8):
208-
209- directory = HERE
210-
211-
212-class TestPyflakes(styles.TestPyflakes):
213-
214- directory = HERE
215
216=== removed file 'lander/lander/tests/test_style.py'
217--- lander/lander/tests/test_style.py 2014-10-07 10:04:01 +0000
218+++ lander/lander/tests/test_style.py 1970-01-01 00:00:00 +0000
219@@ -1,42 +0,0 @@
220-# Ubuntu CI Engine
221-# Copyright 2014 Canonical Ltd.
222-
223-# This program is free software: you can redistribute it and/or modify it
224-# under the terms of the GNU Affero General Public License version 3, as
225-# published by the Free Software Foundation.
226-
227-# This program is distributed in the hope that it will be useful, but
228-# WITHOUT ANY WARRANTY; without even the implied warranties of
229-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
230-# PURPOSE. See the GNU Affero General Public License for more details.
231-
232-# You should have received a copy of the GNU Affero General Public License
233-# along with this program. If not, see <http://www.gnu.org/licenses/>.
234-
235-import os
236-from ucitests import styles
237-
238-import lander
239-from testing import styles as testing_styles
240-
241-HERE = os.path.abspath(os.path.dirname(__file__))
242-
243-
244-class TestPep8(styles.TestPep8):
245-
246- packages = [lander]
247-
248-
249-class TestPyflakes(styles.TestPyflakes):
250-
251- packages = [lander]
252-
253-
254-class TestPep8Bin(testing_styles.TestPep8):
255-
256- directory = os.path.join(HERE, '..', '..', 'bin')
257-
258-
259-class TestPyflakesBin(testing_styles.TestPyflakes):
260-
261- directory = os.path.join(HERE, '..', '..', 'bin')
262
263=== removed file 'ppa-creator/ppacreator/tests/test_style.py'
264--- ppa-creator/ppacreator/tests/test_style.py 2014-07-30 21:44:23 +0000
265+++ ppa-creator/ppacreator/tests/test_style.py 1970-01-01 00:00:00 +0000
266@@ -1,28 +0,0 @@
267-# Ubuntu CI Engine
268-# Copyright 2014 Canonical Ltd.
269-
270-# This program is free software: you can redistribute it and/or modify it
271-# under the terms of the GNU Affero General Public License version 3, as
272-# published by the Free Software Foundation.
273-
274-# This program is distributed in the hope that it will be useful, but
275-# WITHOUT ANY WARRANTY; without even the implied warranties of
276-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
277-# PURPOSE. See the GNU Affero General Public License for more details.
278-
279-# You should have received a copy of the GNU Affero General Public License
280-# along with this program. If not, see <http://www.gnu.org/licenses/>.
281-
282-from ucitests import styles
283-
284-import ppacreator
285-
286-
287-class TestPep8(styles.TestPep8):
288-
289- packages = [ppacreator]
290-
291-
292-class TestPyflakes(styles.TestPyflakes):
293-
294- packages = [ppacreator]
295
296=== removed file 'publisher/publisher/tests/test_style.py'
297--- publisher/publisher/tests/test_style.py 2014-10-07 10:04:01 +0000
298+++ publisher/publisher/tests/test_style.py 1970-01-01 00:00:00 +0000
299@@ -1,42 +0,0 @@
300-# Ubuntu CI Engine
301-# Copyright 2014 Canonical Ltd.
302-
303-# This program is free software: you can redistribute it and/or modify it
304-# under the terms of the GNU Affero General Public License version 3, as
305-# published by the Free Software Foundation.
306-
307-# This program is distributed in the hope that it will be useful, but
308-# WITHOUT ANY WARRANTY; without even the implied warranties of
309-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
310-# PURPOSE. See the GNU Affero General Public License for more details.
311-
312-# You should have received a copy of the GNU Affero General Public License
313-# along with this program. If not, see <http://www.gnu.org/licenses/>.
314-
315-import os
316-from ucitests import styles
317-
318-import publisher
319-from testing import styles as testing_styles
320-
321-HERE = os.path.abspath(os.path.dirname(__file__))
322-
323-
324-class TestPep8(styles.TestPep8):
325-
326- packages = [publisher]
327-
328-
329-class TestPyflakes(styles.TestPyflakes):
330-
331- packages = [publisher]
332-
333-
334-class TestPep8Bin(testing_styles.TestPep8):
335-
336- directory = os.path.join(HERE, '..', '..', 'bin')
337-
338-
339-class TestPyflakesBin(testing_styles.TestPyflakes):
340-
341- directory = os.path.join(HERE, '..', '..', 'bin')
342
343=== removed file 'test_runner/tstrun/tests/test_style.py'
344--- test_runner/tstrun/tests/test_style.py 2014-02-15 12:06:40 +0000
345+++ test_runner/tstrun/tests/test_style.py 1970-01-01 00:00:00 +0000
346@@ -1,28 +0,0 @@
347-# Ubuntu CI Engine
348-# Copyright 2014 Canonical Ltd.
349-
350-# This program is free software: you can redistribute it and/or modify it
351-# under the terms of the GNU Affero General Public License version 3, as
352-# published by the Free Software Foundation.
353-
354-# This program is distributed in the hope that it will be useful, but
355-# WITHOUT ANY WARRANTY; without even the implied warranties of
356-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
357-# PURPOSE. See the GNU Affero General Public License for more details.
358-
359-# You should have received a copy of the GNU Affero General Public License
360-# along with this program. If not, see <http://www.gnu.org/licenses/>.
361-
362-from ucitests import styles
363-
364-import tstrun
365-
366-
367-class TestPep8(styles.TestPep8):
368-
369- packages = [tstrun]
370-
371-
372-class TestPyflakes(styles.TestPyflakes):
373-
374- packages = [tstrun]
375
376=== renamed file 'tests/deployers.py' => 'testing/deployers.py'
377=== modified file 'testing/run_tests.py'
378--- testing/run_tests.py 2014-11-03 21:04:50 +0000
379+++ testing/run_tests.py 2014-11-25 17:16:49 +0000
380@@ -308,7 +308,7 @@
381
382 :return: The test suite for all collected tests.
383 """
384- components = ['juju-deployer']
385+ components = ['juju-deployer', 'tests/project', 'bin']
386 loader = loaders.Loader()
387 suite = loader.suiteClass()
388 for c in components:
389@@ -330,7 +330,7 @@
390 """
391 loader = loaders.Loader()
392 suite = loader.suiteClass()
393- suite.addTests(loader.loadTestsFromTree('tests'))
394+ suite.addTests(loader.loadTestsFromTree('tests/integration'))
395 suite = filters.include_regexps(include_regexps, suite)
396 suite = filters.exclude_regexps(exclude_regexps, suite)
397 return suite
398
399=== removed file 'testing/styles.py'
400--- testing/styles.py 2014-06-19 10:07:29 +0000
401+++ testing/styles.py 1970-01-01 00:00:00 +0000
402@@ -1,72 +0,0 @@
403-# Ubuntu CI Engine
404-# Copyright 2014 Canonical Ltd.
405-
406-# This program is free software: you can redistribute it and/or modify it
407-# under the terms of the GNU Affero General Public License version 3, as
408-# published by the Free Software Foundation.
409-
410-# This program is distributed in the hope that it will be useful, but
411-# WITHOUT ANY WARRANTY; without even the implied warranties of
412-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
413-# PURPOSE. See the GNU Affero General Public License for more details.
414-
415-# You should have received a copy of the GNU Affero General Public License
416-# along with this program. If not, see <http://www.gnu.org/licenses/>.
417-"""Helpers to implement style tests.
418-
419-uci-tests relies on the assumption that all tests reside in python
420-packages. This isn't true for some of the uci-engine tests. The classes below
421-provide a directory where test files should be checked instead.
422-"""
423-
424-
425-import cStringIO
426-import os
427-
428-
429-from ucitests import (
430- assertions,
431- styles,
432-)
433-
434-
435-class TestPep8(styles.TestPep8):
436-
437- directory = None
438-
439- def test_pep8_conformance(self):
440- self.assertIsNot(None, self.directory,
441- 'You should define the directory to check')
442- self.pep8style.input_dir(self.directory)
443- self.assertEqual([], self.report._msgs,
444- '\n'.join(self.report._msgs))
445-
446-
447-class TestPyflakes(styles.TestPyflakes):
448-
449- directory = None
450-
451- def test_pyflakes_conformance(self):
452- from pyflakes import (
453- api,
454- reporter,
455- )
456- self.assertIsNot(None, self.directory,
457- 'You should define the directory to check')
458- out = cStringIO.StringIO()
459- err = cStringIO.StringIO()
460- report = reporter.Reporter(out, err)
461- paths = [self.directory]
462-
463- walker = styles.PythonFileWalker(None)
464- for p in paths:
465- root, base = os.path.split(p)
466- sw = walker.SubWalker(root)
467- styles.pyflakes_check_dir(sw, base, self.excludes,
468- api.checkPath, report)
469- out_val = out.getvalue()
470- if out_val:
471- assertions.assertMultiLineAlmostEqual(self, '', out_val)
472- err_val = err.getvalue()
473- if err_val:
474- assertions.assertMultiLineAlmostEqual(self, '', err_val)
475
476=== removed file 'testing/test_style.py'
477--- testing/test_style.py 2014-06-13 10:38:02 +0000
478+++ testing/test_style.py 1970-01-01 00:00:00 +0000
479@@ -1,28 +0,0 @@
480-# Ubuntu CI Engine
481-# Copyright 2014 Canonical Ltd.
482-
483-# This program is free software: you can redistribute it and/or modify it
484-# under the terms of the GNU Affero General Public License version 3, as
485-# published by the Free Software Foundation.
486-
487-# This program is distributed in the hope that it will be useful, but
488-# WITHOUT ANY WARRANTY; without even the implied warranties of
489-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
490-# PURPOSE. See the GNU Affero General Public License for more details.
491-
492-# You should have received a copy of the GNU Affero General Public License
493-# along with this program. If not, see <http://www.gnu.org/licenses/>.
494-
495-from ucitests import styles
496-
497-import testing
498-
499-
500-class TestPep8(styles.TestPep8):
501-
502- packages = [testing]
503-
504-
505-class TestPyflakes(styles.TestPyflakes):
506-
507- packages = [testing]
508
509=== added directory 'tests/integration'
510=== added file 'tests/integration/__init__.py'
511=== renamed file 'tests/test_britney.py' => 'tests/integration/test_britney.py'
512--- tests/test_britney.py 2014-11-03 12:59:48 +0000
513+++ tests/integration/test_britney.py 2014-11-25 17:16:49 +0000
514@@ -25,7 +25,7 @@
515 image_store,
516 )
517 import deploy
518-import deployers
519+from testing import deployers
520 from ucitests import (
521 assertions,
522 fixtures,
523
524=== renamed file 'tests/test_bsbuilder.py' => 'tests/integration/test_bsbuilder.py'
525--- tests/test_bsbuilder.py 2014-06-23 19:41:51 +0000
526+++ tests/integration/test_bsbuilder.py 2014-11-25 17:16:49 +0000
527@@ -16,7 +16,7 @@
528
529
530 import unittest
531-import deployers
532+from testing import deployers
533
534
535 class TestBsBuilder(deployers.DeployerTest):
536
537=== renamed file 'tests/test_data_store.py' => 'tests/integration/test_data_store.py'
538=== renamed file 'tests/test_image_builder.py' => 'tests/integration/test_image_builder.py'
539--- tests/test_image_builder.py 2014-10-07 10:04:01 +0000
540+++ tests/integration/test_image_builder.py 2014-11-25 17:16:49 +0000
541@@ -16,7 +16,7 @@
542
543
544 import unittest
545-import deployers
546+from testing import deployers
547
548
549 class TestImageBuilder(deployers.DeployerTest):
550
551=== renamed file 'tests/test_image_store.py' => 'tests/integration/test_image_store.py'
552=== renamed file 'tests/test_ppacreator.py' => 'tests/integration/test_ppacreator.py'
553--- tests/test_ppacreator.py 2014-10-30 20:46:10 +0000
554+++ tests/integration/test_ppacreator.py 2014-11-25 17:16:49 +0000
555@@ -17,7 +17,7 @@
556 import json
557 import uuid
558 import unittest
559-import deployers
560+from testing import deployers
561 import deploy
562
563 from ci_utils import amqp_utils
564
565=== renamed file 'tests/test_publisher.py' => 'tests/integration/test_publisher.py'
566--- tests/test_publisher.py 2014-10-07 10:04:01 +0000
567+++ tests/integration/test_publisher.py 2014-11-25 17:16:49 +0000
568@@ -18,7 +18,7 @@
569
570
571 import unittest
572-import deployers
573+from testing import deployers
574
575
576 class TestPublisher(deployers.DeployerTest):
577
578=== renamed file 'tests/test_rabbit.py' => 'tests/integration/test_rabbit.py'
579--- tests/test_rabbit.py 2014-10-23 14:07:48 +0000
580+++ tests/integration/test_rabbit.py 2014-11-25 17:16:49 +0000
581@@ -14,7 +14,7 @@
582 # along with this program. If not, see <http://www.gnu.org/licenses/>.
583 import unittest
584
585-import deployers
586+from testing import deployers
587 from ucitests import fixtures
588
589 from ci_utils import amqp_utils
590
591=== renamed file 'tests/test_test_runner.py' => 'tests/integration/test_test_runner.py'
592--- tests/test_test_runner.py 2014-10-15 10:35:04 +0000
593+++ tests/integration/test_test_runner.py 2014-11-25 17:16:49 +0000
594@@ -24,7 +24,7 @@
595 image_store,
596 )
597 import deploy
598-import deployers
599+from testing import deployers
600 from ucitests import (
601 assertions,
602 )
603
604=== renamed file 'tests/test_ticket_system.py' => 'tests/integration/test_ticket_system.py'
605--- tests/test_ticket_system.py 2014-11-25 01:21:41 +0000
606+++ tests/integration/test_ticket_system.py 2014-11-25 17:16:49 +0000
607@@ -16,7 +16,7 @@
608 import httplib2
609 import json
610 import unittest
611-import deployers
612+from testing import deployers
613
614 from ci_utils.ticket_states import TicketWorkflowStep
615
616
617=== renamed file 'tests/test_validator.py' => 'tests/integration/test_validator.py'
618--- tests/test_validator.py 2014-08-14 17:21:56 +0000
619+++ tests/integration/test_validator.py 2014-11-25 17:16:49 +0000
620@@ -15,7 +15,7 @@
621 # along with this program. If not, see <http://www.gnu.org/licenses/>.
622
623 import unittest
624-import deployers
625+from testing import deployers
626
627
628 class TestValidator(deployers.DeployerTest):
629
630=== renamed file 'tests/test_webui.py' => 'tests/integration/test_webui.py'
631--- tests/test_webui.py 2014-11-12 12:32:19 +0000
632+++ tests/integration/test_webui.py 2014-11-25 17:16:49 +0000
633@@ -32,7 +32,7 @@
634 cases,
635 )
636
637-import deployers
638+from testing import deployers
639
640
641 class WebUITest(cases.SSTTestCase):
642
643=== added directory 'tests/project'
644=== added file 'tests/project/__init__.py'
645=== renamed file 'tests/test_style.py' => 'tests/project/test_static.py'
646--- tests/test_style.py 2014-11-10 09:49:20 +0000
647+++ tests/project/test_static.py 2014-11-25 17:16:49 +0000
648@@ -13,40 +13,11 @@
649 # You should have received a copy of the GNU Affero General Public License
650 # along with this program. If not, see <http://www.gnu.org/licenses/>.
651
652-import os
653 import subprocess
654 import unittest
655
656
657-HERE = os.path.abspath(os.path.dirname(__file__))
658-
659-
660-from testing import styles
661-
662-
663-class TestPep8(styles.TestPep8):
664-
665- directory = HERE
666-
667-
668-class TestPyflakes(styles.TestPyflakes):
669-
670- directory = HERE
671-
672-
673-class TestBinPep8(styles.TestPep8):
674- """Pep8 tests for the 'bin' directory in branch root."""
675-
676- directory = os.path.abspath(os.path.join(HERE, '..', 'bin'))
677-
678-
679-class TestBinPyflakes(styles.TestPyflakes):
680- """Pyflakes tests for the 'bin' directory in branch root."""
681-
682- directory = os.path.abspath(os.path.join(HERE, '..', 'bin'))
683-
684-
685-class TestNoExit(unittest.TestCase):
686+class TestStatic(unittest.TestCase):
687
688 def test_no_bare_exit(self):
689 output = subprocess.check_output(
690@@ -58,3 +29,12 @@
691 https://docs.python.org/2/library/constants.html#exit
692 Please use sys.exit() below:
693 ''' + output)
694+
695+ def test_python_shebang(self):
696+ output = subprocess.check_output(
697+ ['bzr', 'grep', '--from-root', '-n', '^#!/.*/python'])
698+ msg = ('''
699+Do not call /usr/bin/python directly in a shebang (#!) as this breaks
700+virtualenv. Instead, use '#!/usr/bin/env python' in the instances below:
701+''' + output)
702+ self.assertEqual('', output, msg=msg)
703
704=== added file 'tests/project/test_syntax.py'
705--- tests/project/test_syntax.py 1970-01-01 00:00:00 +0000
706+++ tests/project/test_syntax.py 2014-11-25 17:16:49 +0000
707@@ -0,0 +1,44 @@
708+# Rather than opt-in to PEP8 and pyflakes testing module-by-module, these tests
709+# cover all python code, non-module code included, with an explicit opt-out.
710+
711+import os
712+import sys
713+import pep8
714+import cStringIO
715+from pyflakes import api, reporter
716+import unittest
717+
718+
719+HERE = os.path.abspath(os.path.dirname(__file__))
720+ROOT = os.path.abspath(os.path.join(HERE, '..'))
721+EXCLUDE = [
722+ # Migrations are automatically generated.
723+ 'migrations',
724+ # TODO ev 2014-11-15 cupstream2distro is an understood mess.
725+ 'cupstream2distro',
726+ # An arguably reasonable use of star imports.
727+ 'ticket_system/ticket/tests/__init__.py',
728+]
729+
730+
731+class TestSyntax(unittest.TestCase):
732+ def test_pep8(self):
733+ guide = pep8.StyleGuide(paths=[ROOT], exclude=EXCLUDE)
734+ report = guide.check_files()
735+ errors = report.total_errors
736+ self.assertEqual(errors, 0, '%d PEP8 errors.' % errors)
737+
738+ def test_pyflakes(self):
739+ (out, err) = (cStringIO.StringIO(), cStringIO.StringIO())
740+ report = reporter.Reporter(out, err)
741+ errors = 0
742+ for dirpath, dirnames, filenames in os.walk(ROOT):
743+ for filename in filenames:
744+ path = os.path.join(dirpath, filename)
745+ excluded = any(excl in path for excl in EXCLUDE)
746+ if filename.endswith('.py') and not excluded:
747+ errors += api.checkPath(path, report)
748+ error_text = out.getvalue()
749+ if error_text:
750+ print >>sys.stderr, '\n%s' % error_text
751+ self.assertEqual(errors, 0, '%d pyflakes errors.' % errors)
752
753=== modified file 'ticket_system/project/tests.py'
754--- ticket_system/project/tests.py 2014-02-15 12:06:40 +0000
755+++ ticket_system/project/tests.py 2014-11-25 17:16:49 +0000
756@@ -168,18 +168,3 @@
757 def test_delete_binarypackage_not_allowed(self):
758 resp = self.delete(resource=self.detail_url)
759 self.assertHttpMethodNotAllowed(resp)
760-
761-
762-class TestPep8(styles.TestPep8):
763-
764- packages = [project]
765- exclude = ['migrations/']
766-
767-
768-class TestPyflakes(styles.TestPyflakes):
769-
770- packages = [project]
771- # pyflakes dislikes 'from module import *'
772- excludes = ['project/tests/__init__.py',
773- # Ignore generated migrations files
774- 'project/migrations/0001_initial.py']
775
776=== removed file 'ticket_system/ticket/tests/test_style.py'
777--- ticket_system/ticket/tests/test_style.py 2014-10-07 10:04:01 +0000
778+++ ticket_system/ticket/tests/test_style.py 1970-01-01 00:00:00 +0000
779@@ -1,38 +0,0 @@
780-# Ubuntu CI Engine
781-# Copyright 2014 Canonical Ltd.
782-
783-# This program is free software: you can redistribute it and/or modify it
784-# under the terms of the GNU Affero General Public License version 3, as
785-# published by the Free Software Foundation.
786-
787-# This program is distributed in the hope that it will be useful, but
788-# WITHOUT ANY WARRANTY; without even the implied warranties of
789-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
790-# PURPOSE. See the GNU Affero General Public License for more details.
791-
792-# You should have received a copy of the GNU Affero General Public License
793-# along with this program. If not, see <http://www.gnu.org/licenses/>.
794-
795-import os
796-
797-from ucitests import styles
798-
799-import ticket
800-
801-
802-HERE = os.path.abspath(os.path.dirname(__file__))
803-
804-
805-class TestPep8(styles.TestPep8):
806-
807- packages = [ticket]
808- exclude = ['migrations/']
809-
810-
811-class TestPyflakes(styles.TestPyflakes):
812-
813- packages = [ticket]
814- migrations = ['ticket/migrations/' + x
815- for x in os.listdir(os.path.join(HERE, '..', 'migrations'))]
816- # pyflakes dislikes 'from module import *'
817- excludes = ['ticket/tests/__init__.py'] + migrations
818
819=== removed file 'validator/validator/tests/test_style.py'
820--- validator/validator/tests/test_style.py 2014-08-12 13:51:42 +0000
821+++ validator/validator/tests/test_style.py 1970-01-01 00:00:00 +0000
822@@ -1,42 +0,0 @@
823-# Ubuntu CI Engine
824-# Copyright 2014 Canonical Ltd.
825-
826-# This program is free software: you can redistribute it and/or modify it
827-# under the terms of the GNU Affero General Public License version 3, as
828-# published by the Free Software Foundation.
829-
830-# This program is distributed in the hope that it will be useful, but
831-# WITHOUT ANY WARRANTY; without even the implied warranties of
832-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
833-# PURPOSE. See the GNU Affero General Public License for more details.
834-
835-# You should have received a copy of the GNU Affero General Public License
836-# along with this program. If not, see <http://www.gnu.org/licenses/>.
837-
838-import os
839-from ucitests import styles
840-
841-import validator
842-from testing import styles as testing_styles
843-
844-HERE = os.path.abspath(os.path.dirname(__file__))
845-
846-
847-class TestPep8(styles.TestPep8):
848-
849- packages = [validator]
850-
851-
852-class TestPyflakes(styles.TestPyflakes):
853-
854- packages = [validator]
855-
856-
857-class TestPep8Bin(testing_styles.TestPep8):
858-
859- directory = os.path.join(HERE, '..', '..', 'bin')
860-
861-
862-class TestPyflakesBin(testing_styles.TestPyflakes):
863-
864- directory = os.path.join(HERE, '..', '..', 'bin')
865
866=== modified file 'webui/status/tests.py'
867--- webui/status/tests.py 2014-07-23 13:31:29 +0000
868+++ webui/status/tests.py 2014-11-25 17:16:49 +0000
869@@ -90,11 +90,3 @@
870 ]
871 errors = _find_json_health_errors()
872 self.assertEqual(2, len(errors))
873-
874-
875-class TestPep8(styles.TestPep8):
876- packages = [status]
877-
878-
879-class TestPyflakes(styles.TestPyflakes):
880- packages = [status]

Subscribers

People subscribed via source and target branches

to all changes: