Merge lp:~cjwatson/launchpad/code-browser-tests-future-imports into lp:launchpad
- code-browser-tests-future-imports
- Merge into devel
Status: | Merged |
---|---|
Merged at revision: | 18477 |
Proposed branch: | lp:~cjwatson/launchpad/code-browser-tests-future-imports |
Merge into: | lp:launchpad |
Diff against target: |
1206 lines (+211/-167) 24 files modified
lib/lp/code/browser/tests/test_bazaar.py (+3/-1) lib/lp/code/browser/tests/test_branch.py (+2/-0) lib/lp/code/browser/tests/test_branchlisting.py (+3/-1) lib/lp/code/browser/tests/test_branchmergeproposal.py (+26/-24) lib/lp/code/browser/tests/test_branchmergeproposallisting.py (+3/-1) lib/lp/code/browser/tests/test_branchsubscription.py (+3/-1) lib/lp/code/browser/tests/test_branchtraversal.py (+3/-1) lib/lp/code/browser/tests/test_breadcrumbs.py (+3/-1) lib/lp/code/browser/tests/test_codeimport.py (+3/-1) lib/lp/code/browser/tests/test_codereviewcomment.py (+6/-4) lib/lp/code/browser/tests/test_codereviewvote.py (+3/-1) lib/lp/code/browser/tests/test_diff.py (+5/-3) lib/lp/code/browser/tests/test_gitlisting.py (+39/-37) lib/lp/code/browser/tests/test_gitref.py (+24/-22) lib/lp/code/browser/tests/test_gitrepository.py (+18/-16) lib/lp/code/browser/tests/test_gitsubscription.py (+3/-1) lib/lp/code/browser/tests/test_product.py (+3/-1) lib/lp/code/browser/tests/test_revisionauthor.py (+3/-1) lib/lp/code/browser/tests/test_sourcepackagerecipe.py (+35/-35) lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py (+5/-2) lib/lp/code/browser/tests/test_sourcepackagerecipelisting.py (+3/-2) lib/lp/code/browser/tests/test_tales.py (+8/-6) lib/lp/code/browser/tests/test_vcslisting.py (+3/-1) lib/lp/code/browser/tests/test_views.py (+4/-4) |
To merge this branch: | bzr merge lp:~cjwatson/launchpad/code-browser-tests-future-imports |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+331758@code.launchpad.net |
Commit message
Convert lp.code.
Description of the change
We've had a reasonably modern set of __future__ imports in standard_
For the most part Launchpad is pretty clean for a codebase of its size and age, since most textual data of any significance goes through database text columns which are already Unicode; SQLObject-flavoured models tolerate receiving bytes, but switching to Unicode literals mostly just works. The main adjustments needed in this branch were in diff-related tests, where some of the input files are non-UTF-8.
William Grant (wgrant) : | # |
Preview Diff
1 | === modified file 'lib/lp/code/browser/tests/test_bazaar.py' |
2 | --- lib/lp/code/browser/tests/test_bazaar.py 2012-09-18 18:36:09 +0000 |
3 | +++ lib/lp/code/browser/tests/test_bazaar.py 2017-10-04 01:26:22 +0000 |
4 | @@ -1,8 +1,10 @@ |
5 | -# Copyright 2009-2012 Canonical Ltd. This software is licensed under the |
6 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
7 | # GNU Affero General Public License version 3 (see the file LICENSE). |
8 | |
9 | """Tests for classes in the lp.code.browser.bazaar module.""" |
10 | |
11 | +from __future__ import absolute_import, print_function, unicode_literals |
12 | + |
13 | __metaclass__ = type |
14 | |
15 | from zope.security.proxy import removeSecurityProxy |
16 | |
17 | === modified file 'lib/lp/code/browser/tests/test_branch.py' |
18 | --- lib/lp/code/browser/tests/test_branch.py 2017-05-08 11:38:20 +0000 |
19 | +++ lib/lp/code/browser/tests/test_branch.py 2017-10-04 01:26:22 +0000 |
20 | @@ -3,6 +3,8 @@ |
21 | |
22 | """Unit tests for BranchView.""" |
23 | |
24 | +from __future__ import absolute_import, print_function, unicode_literals |
25 | + |
26 | __metaclass__ = type |
27 | |
28 | from datetime import datetime |
29 | |
30 | === modified file 'lib/lp/code/browser/tests/test_branchlisting.py' |
31 | --- lib/lp/code/browser/tests/test_branchlisting.py 2017-06-15 01:02:11 +0000 |
32 | +++ lib/lp/code/browser/tests/test_branchlisting.py 2017-10-04 01:26:22 +0000 |
33 | @@ -3,6 +3,8 @@ |
34 | |
35 | """Tests for branch listing.""" |
36 | |
37 | +from __future__ import absolute_import, print_function, unicode_literals |
38 | + |
39 | __metaclass__ = type |
40 | |
41 | from datetime import timedelta |
42 | @@ -78,7 +80,7 @@ |
43 | view_name='+branches'): |
44 | # The Javascript to wire up the ajax batch navigation behaviour is |
45 | # correctly hidden behind a feature flag. |
46 | - flags = {u"ajax.batch_navigator.enabled": u"true"} |
47 | + flags = {"ajax.batch_navigator.enabled": "true"} |
48 | with FeatureFixture(flags): |
49 | view = create_initialized_view( |
50 | context, name=view_name, rootsite='code', principal=user) |
51 | |
52 | === modified file 'lib/lp/code/browser/tests/test_branchmergeproposal.py' |
53 | --- lib/lp/code/browser/tests/test_branchmergeproposal.py 2017-05-24 12:04:18 +0000 |
54 | +++ lib/lp/code/browser/tests/test_branchmergeproposal.py 2017-10-04 01:26:22 +0000 |
55 | @@ -3,6 +3,8 @@ |
56 | |
57 | """Unit tests for BranchMergeProposals.""" |
58 | |
59 | +from __future__ import absolute_import, print_function, unicode_literals |
60 | + |
61 | __metaclass__ = type |
62 | |
63 | from datetime import ( |
64 | @@ -1365,8 +1367,8 @@ |
65 | |
66 | def test_preview_diff_all_chars(self): |
67 | """preview_diff should work on diffs containing all possible bytes.""" |
68 | - text = ''.join(chr(x) for x in range(255)) |
69 | - diff_bytes = ''.join(unified_diff('', text)) |
70 | + text = b''.join(chr(x) for x in range(255)) |
71 | + diff_bytes = b''.join(unified_diff(b'', text)) |
72 | self.setPreviewDiff(diff_bytes) |
73 | transaction.commit() |
74 | view = create_initialized_view(self.bmp, '+index') |
75 | @@ -1377,8 +1379,8 @@ |
76 | def test_preview_diff_timeout(self): |
77 | # The preview_diff will recover from a timeout set to get the |
78 | # librarian content. |
79 | - text = ''.join(chr(x) for x in range(255)) |
80 | - diff_bytes = ''.join(unified_diff('', text)) |
81 | + text = b''.join(chr(x) for x in range(255)) |
82 | + diff_bytes = b''.join(unified_diff(b'', text)) |
83 | preview_diff = self.setPreviewDiff(diff_bytes) |
84 | transaction.commit() |
85 | |
86 | @@ -1395,7 +1397,7 @@ |
87 | |
88 | def setPreviewDiff(self, preview_diff_bytes): |
89 | return PreviewDiff.create( |
90 | - self.bmp, preview_diff_bytes, u'a', u'b', None, u'') |
91 | + self.bmp, preview_diff_bytes, 'a', 'b', None, '') |
92 | |
93 | def test_linked_bugtasks_excludes_mutual_bugs(self): |
94 | """List bugs that are linked to the source only.""" |
95 | @@ -1453,7 +1455,7 @@ |
96 | old_revision=revisions[1].revision.getLefthandParent(), |
97 | new_revision=revisions[3].revision) |
98 | self.useContext(feature_flags()) |
99 | - set_feature_flag(u'code.incremental_diffs.enabled', u'enabled') |
100 | + set_feature_flag('code.incremental_diffs.enabled', 'enabled') |
101 | view = create_initialized_view(bmp, '+index') |
102 | comments = view.conversation.comments |
103 | self.assertEqual( |
104 | @@ -1486,12 +1488,12 @@ |
105 | date_created=review_date) |
106 | self.useFixture(GitHostingFixture(log=[ |
107 | { |
108 | - u'sha1': unicode(hashlib.sha1(b'0').hexdigest()), |
109 | - u'message': u'0', |
110 | - u'author': { |
111 | - u'name': author.display_name, |
112 | - u'email': author_email, |
113 | - u'time': int((commit_date - epoch).total_seconds()), |
114 | + 'sha1': unicode(hashlib.sha1(b'0').hexdigest()), |
115 | + 'message': '0', |
116 | + 'author': { |
117 | + 'name': author.display_name, |
118 | + 'email': author_email, |
119 | + 'time': int((commit_date - epoch).total_seconds()), |
120 | }, |
121 | } |
122 | ])) |
123 | @@ -1551,7 +1553,7 @@ |
124 | # subscribed to events relating to the merge proposal. |
125 | bmp = self.factory.makeBranchMergeProposal() |
126 | self.useContext(feature_flags()) |
127 | - set_feature_flag(u'longpoll.merge_proposals.enabled', u'enabled') |
128 | + set_feature_flag('longpoll.merge_proposals.enabled', 'enabled') |
129 | view = create_initialized_view(bmp, '+index', current_request=True) |
130 | cache = IJSONRequestCache(view.request) |
131 | self.assertIn("longpoll", cache.objects) |
132 | @@ -1582,12 +1584,12 @@ |
133 | commit_date = datetime(2015, 1, 1, tzinfo=pytz.UTC) |
134 | self.useFixture(GitHostingFixture(log=[ |
135 | { |
136 | - u'sha1': sha1, |
137 | - u'message': u'Sample message', |
138 | - u'author': { |
139 | - u'name': 'Example Person', |
140 | - u'email': 'person@example.org', |
141 | - u'time': int((commit_date - epoch).total_seconds()), |
142 | + 'sha1': sha1, |
143 | + 'message': 'Sample message', |
144 | + 'author': { |
145 | + 'name': 'Example Person', |
146 | + 'email': 'person@example.org', |
147 | + 'time': int((commit_date - epoch).total_seconds()), |
148 | }, |
149 | } |
150 | ])) |
151 | @@ -1891,7 +1893,7 @@ |
152 | |
153 | def test_nonascii_in_attachment_renders(self): |
154 | # The view should render without errors. |
155 | - comment = self._makeCommentFromEmailWithAttachment('\xe2\x98\x95') |
156 | + comment = self._makeCommentFromEmailWithAttachment(b'\xe2\x98\x95') |
157 | # Need to commit in order to read the diff out of the librarian. |
158 | transaction.commit() |
159 | view = create_initialized_view(comment, '+comment-body') |
160 | @@ -1899,12 +1901,12 @@ |
161 | |
162 | def test_nonascii_in_attachment_decoded(self): |
163 | # The diff_text should be a unicode string. |
164 | - comment = self._makeCommentFromEmailWithAttachment('\xe2\x98\x95') |
165 | + comment = self._makeCommentFromEmailWithAttachment(b'\xe2\x98\x95') |
166 | # Need to commit in order to read the diff out of the librarian. |
167 | transaction.commit() |
168 | view = create_initialized_view(comment, '+comment-body') |
169 | [diff_attachment] = view.comment.display_attachments |
170 | - self.assertEqual(u'\u2615', diff_attachment.diff_text) |
171 | + self.assertEqual('\u2615', diff_attachment.diff_text) |
172 | |
173 | |
174 | class TestBranchMergeCandidateView(TestCaseWithFactory): |
175 | @@ -1960,7 +1962,7 @@ |
176 | diff = self.factory.makeDiff() |
177 | bmp.generateIncrementalDiff(parent, revision, diff) |
178 | self.useContext(feature_flags()) |
179 | - set_feature_flag(u'code.incremental_diffs.enabled', u'enabled') |
180 | + set_feature_flag('code.incremental_diffs.enabled', 'enabled') |
181 | browser = self.getViewBrowser(bmp) |
182 | assert 'unf_pbasyvpgf' in browser.contents |
183 | |
184 | @@ -1970,7 +1972,7 @@ |
185 | # automatically. See also |
186 | # lib/lp/code/stories/branches/xx-branchmergeproposals.txt |
187 | self.useContext(feature_flags()) |
188 | - set_feature_flag(u'longpoll.merge_proposals.enabled', u'enabled') |
189 | + set_feature_flag('longpoll.merge_proposals.enabled', 'enabled') |
190 | bmp = self.factory.makeBranchMergeProposal() |
191 | browser = self.getViewBrowser(bmp) |
192 | self.assertIn( |
193 | |
194 | === modified file 'lib/lp/code/browser/tests/test_branchmergeproposallisting.py' |
195 | --- lib/lp/code/browser/tests/test_branchmergeproposallisting.py 2015-10-14 12:50:55 +0000 |
196 | +++ lib/lp/code/browser/tests/test_branchmergeproposallisting.py 2017-10-04 01:26:22 +0000 |
197 | @@ -1,8 +1,10 @@ |
198 | -# Copyright 2009-2015 Canonical Ltd. This software is licensed under the |
199 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
200 | # GNU Affero General Public License version 3 (see the file LICENSE). |
201 | |
202 | """Unit tests for BranchMergeProposal listing views.""" |
203 | |
204 | +from __future__ import absolute_import, print_function, unicode_literals |
205 | + |
206 | __metaclass__ = type |
207 | |
208 | from datetime import datetime |
209 | |
210 | === modified file 'lib/lp/code/browser/tests/test_branchsubscription.py' |
211 | --- lib/lp/code/browser/tests/test_branchsubscription.py 2016-11-09 17:18:21 +0000 |
212 | +++ lib/lp/code/browser/tests/test_branchsubscription.py 2017-10-04 01:26:22 +0000 |
213 | @@ -1,8 +1,10 @@ |
214 | -# Copyright 2009-2016 Canonical Ltd. This software is licensed under the |
215 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
216 | # GNU Affero General Public License version 3 (see the file LICENSE). |
217 | |
218 | """Unit tests for BranchSubscriptions.""" |
219 | |
220 | +from __future__ import absolute_import, print_function, unicode_literals |
221 | + |
222 | __metaclass__ = type |
223 | |
224 | from lp.app.enums import InformationType |
225 | |
226 | === modified file 'lib/lp/code/browser/tests/test_branchtraversal.py' |
227 | --- lib/lp/code/browser/tests/test_branchtraversal.py 2012-01-01 02:58:52 +0000 |
228 | +++ lib/lp/code/browser/tests/test_branchtraversal.py 2017-10-04 01:26:22 +0000 |
229 | @@ -1,8 +1,10 @@ |
230 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
231 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
232 | # GNU Affero General Public License version 3 (see the file LICENSE). |
233 | |
234 | """Tests for branch traversal.""" |
235 | |
236 | +from __future__ import absolute_import, print_function, unicode_literals |
237 | + |
238 | from zope.component import getUtility |
239 | from zope.publisher.interfaces import NotFound |
240 | from zope.security.proxy import removeSecurityProxy |
241 | |
242 | === modified file 'lib/lp/code/browser/tests/test_breadcrumbs.py' |
243 | --- lib/lp/code/browser/tests/test_breadcrumbs.py 2011-08-12 11:37:08 +0000 |
244 | +++ lib/lp/code/browser/tests/test_breadcrumbs.py 2017-10-04 01:26:22 +0000 |
245 | @@ -1,6 +1,8 @@ |
246 | -# Copyright 2010 Canonical Ltd. This software is licensed under the |
247 | +# Copyright 2010-2017 Canonical Ltd. This software is licensed under the |
248 | # GNU Affero General Public License version 3 (see the file LICENSE). |
249 | |
250 | +from __future__ import absolute_import, print_function, unicode_literals |
251 | + |
252 | __metaclass__ = type |
253 | |
254 | from lp.testing.breadcrumbs import BaseBreadcrumbTestCase |
255 | |
256 | === modified file 'lib/lp/code/browser/tests/test_codeimport.py' |
257 | --- lib/lp/code/browser/tests/test_codeimport.py 2016-10-13 12:43:14 +0000 |
258 | +++ lib/lp/code/browser/tests/test_codeimport.py 2017-10-04 01:26:22 +0000 |
259 | @@ -1,8 +1,10 @@ |
260 | -# Copyright 2009-2016 Canonical Ltd. This software is licensed under the |
261 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
262 | # GNU Affero General Public License version 3 (see the file LICENSE). |
263 | |
264 | """Tests for the code import browser code.""" |
265 | |
266 | +from __future__ import absolute_import, print_function, unicode_literals |
267 | + |
268 | __metaclass__ = type |
269 | |
270 | import re |
271 | |
272 | === modified file 'lib/lp/code/browser/tests/test_codereviewcomment.py' |
273 | --- lib/lp/code/browser/tests/test_codereviewcomment.py 2016-01-21 01:56:21 +0000 |
274 | +++ lib/lp/code/browser/tests/test_codereviewcomment.py 2017-10-04 01:26:22 +0000 |
275 | @@ -1,8 +1,10 @@ |
276 | -# Copyright 2009-2015 Canonical Ltd. This software is licensed under the |
277 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
278 | # GNU Affero General Public License version 3 (see the file LICENSE). |
279 | |
280 | """Unit tests for CodeReviewComments.""" |
281 | |
282 | +from __future__ import absolute_import, print_function, unicode_literals |
283 | + |
284 | __metaclass__ = type |
285 | |
286 | from soupmatchers import ( |
287 | @@ -158,9 +160,9 @@ |
288 | |
289 | def test_download_view(self): |
290 | """The download view has the expected contents and header.""" |
291 | - comment = self.makeCodeReviewComment(body=u'\u1234') |
292 | + comment = self.makeCodeReviewComment(body='\u1234') |
293 | browser = self.getViewBrowser(comment, view_name='+download') |
294 | - contents = u'\u1234'.encode('utf-8') |
295 | + contents = '\u1234'.encode('utf-8') |
296 | self.assertEqual(contents, browser.contents) |
297 | self.assertEqual( |
298 | 'text/plain;charset=utf-8', browser.headers['Content-type']) |
299 | @@ -171,7 +173,7 @@ |
300 | |
301 | def test_parent_comment_in_reply(self): |
302 | """The reply view has the expected contents from the parent comment.""" |
303 | - contents = u'test-comment'.encode('utf-8') |
304 | + contents = 'test-comment'.encode('utf-8') |
305 | comment = self.makeCodeReviewComment(body=contents) |
306 | browser = self.getViewBrowser(comment, view_name='+reply') |
307 | self.assertIn(contents, browser.contents) |
308 | |
309 | === modified file 'lib/lp/code/browser/tests/test_codereviewvote.py' |
310 | --- lib/lp/code/browser/tests/test_codereviewvote.py 2012-01-01 02:58:52 +0000 |
311 | +++ lib/lp/code/browser/tests/test_codereviewvote.py 2017-10-04 01:26:22 +0000 |
312 | @@ -1,8 +1,10 @@ |
313 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
314 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
315 | # GNU Affero General Public License version 3 (see the file LICENSE). |
316 | |
317 | """Unit tests for CodeReviewVoteReferences.""" |
318 | |
319 | +from __future__ import absolute_import, print_function, unicode_literals |
320 | + |
321 | __metaclass__ = type |
322 | |
323 | from lp.services.webapp import canonical_url |
324 | |
325 | === modified file 'lib/lp/code/browser/tests/test_diff.py' |
326 | --- lib/lp/code/browser/tests/test_diff.py 2012-01-01 02:58:52 +0000 |
327 | +++ lib/lp/code/browser/tests/test_diff.py 2017-10-04 01:26:22 +0000 |
328 | @@ -1,8 +1,10 @@ |
329 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
330 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
331 | # GNU Affero General Public License version 3 (see the file LICENSE). |
332 | |
333 | """Unit tests for DiffView.""" |
334 | |
335 | +from __future__ import absolute_import, print_function, unicode_literals |
336 | + |
337 | from lp.code.browser.diff import PreviewDiffFormatterAPI |
338 | from lp.testing import TestCaseWithFactory |
339 | from lp.testing.layers import LaunchpadFunctionalLayer |
340 | @@ -14,7 +16,7 @@ |
341 | |
342 | def test_empty_conflicts(self): |
343 | """'has conflicts' does not appear if conflicts is empty string.""" |
344 | - diff = self.factory.makePreviewDiff(conflicts=u'') |
345 | + diff = self.factory.makePreviewDiff(conflicts='') |
346 | self.assertEqual('', diff.conflicts) |
347 | formatter = PreviewDiffFormatterAPI(diff) |
348 | self.assertNotIn('has conflicts', formatter.link(None)) |
349 | @@ -28,7 +30,7 @@ |
350 | |
351 | def test_with_conflicts(self): |
352 | """'has conflicts' appears if conflicts is a non-empty string.""" |
353 | - diff = self.factory.makePreviewDiff(conflicts=u'bork') |
354 | + diff = self.factory.makePreviewDiff(conflicts='bork') |
355 | self.assertEqual('bork', diff.conflicts) |
356 | formatter = PreviewDiffFormatterAPI(diff) |
357 | self.assertIn('has conflicts', formatter.link(None)) |
358 | |
359 | === modified file 'lib/lp/code/browser/tests/test_gitlisting.py' |
360 | --- lib/lp/code/browser/tests/test_gitlisting.py 2015-07-13 00:32:12 +0000 |
361 | +++ lib/lp/code/browser/tests/test_gitlisting.py 2017-10-04 01:26:22 +0000 |
362 | @@ -1,8 +1,10 @@ |
363 | -# Copyright 2015 Canonical Ltd. This software is licensed under the |
364 | +# Copyright 2015-2017 Canonical Ltd. This software is licensed under the |
365 | # GNU Affero General Public License version 3 (see the file LICENSE). |
366 | |
367 | """Unit tests for Git listing views.""" |
368 | |
369 | +from __future__ import absolute_import, print_function, unicode_literals |
370 | + |
371 | __metaclass__ = type |
372 | |
373 | from BeautifulSoup import BeautifulSoup |
374 | @@ -31,18 +33,18 @@ |
375 | |
376 | def test_rendering(self): |
377 | main_repo = self.factory.makeGitRepository( |
378 | - owner=self.owner, target=self.target, name=u"foo") |
379 | + owner=self.owner, target=self.target, name="foo") |
380 | self.factory.makeGitRefs( |
381 | main_repo, |
382 | - paths=[u"refs/heads/master", u"refs/heads/1.0", u"refs/tags/1.1"]) |
383 | + paths=["refs/heads/master", "refs/heads/1.0", "refs/tags/1.1"]) |
384 | |
385 | other_repo = self.factory.makeGitRepository( |
386 | - owner=self.factory.makePerson(name=u"contributor"), |
387 | - target=self.target, name=u"foo") |
388 | - self.factory.makeGitRefs(other_repo, paths=[u"refs/heads/bug-1234"]) |
389 | + owner=self.factory.makePerson(name="contributor"), |
390 | + target=self.target, name="foo") |
391 | + self.factory.makeGitRefs(other_repo, paths=["refs/heads/bug-1234"]) |
392 | self.factory.makeGitRepository( |
393 | - owner=self.factory.makePerson(name=u"random"), |
394 | - target=self.target, name=u"bar") |
395 | + owner=self.factory.makePerson(name="random"), |
396 | + target=self.target, name="bar") |
397 | |
398 | with admin_logged_in(): |
399 | getUtility(IGitRepositorySet).setDefaultRepository( |
400 | @@ -73,7 +75,7 @@ |
401 | [link.find(text=True) for link in table.findAll('a')]) |
402 | self.assertEndsWith( |
403 | table.find(text="1.0").parent['href'], |
404 | - u"/~foowner/%s/+git/foo/+ref/1.0" % self.target_path) |
405 | + "/~foowner/%s/+git/foo/+ref/1.0" % self.target_path) |
406 | |
407 | # Other repos are listed. |
408 | table = soup.find( |
409 | @@ -86,7 +88,7 @@ |
410 | self.assertEndsWith( |
411 | table.find( |
412 | text="lp:~contributor/%s" % self.target_path).parent['href'], |
413 | - u"/~contributor/%s/+git/foo" % self.target_path) |
414 | + "/~contributor/%s/+git/foo" % self.target_path) |
415 | |
416 | # But not their branches. |
417 | self.assertNotIn('bug-1234', content) |
418 | @@ -112,8 +114,8 @@ |
419 | |
420 | def test_copes_with_no_default(self): |
421 | self.factory.makeGitRepository( |
422 | - owner=self.factory.makePerson(name=u"contributor"), |
423 | - target=self.target, name=u"foo") |
424 | + owner=self.factory.makePerson(name="contributor"), |
425 | + target=self.target, name="foo") |
426 | |
427 | view = create_initialized_view(self.target, '+git') |
428 | self.assertIs(None, view.default_git_repository) |
429 | @@ -184,14 +186,14 @@ |
430 | |
431 | def test_rendering(self): |
432 | default_repo = self.factory.makeGitRepository( |
433 | - owner=self.owner, target=self.target, name=u"foo") |
434 | + owner=self.owner, target=self.target, name="foo") |
435 | self.factory.makeGitRefs( |
436 | default_repo, |
437 | - paths=[u"refs/heads/master", u"refs/heads/bug-1234"]) |
438 | + paths=["refs/heads/master", "refs/heads/bug-1234"]) |
439 | |
440 | other_repo = self.factory.makeGitRepository( |
441 | - owner=self.owner, target=self.target, name=u"bar") |
442 | - self.factory.makeGitRefs(other_repo, paths=[u"refs/heads/bug-2468"]) |
443 | + owner=self.owner, target=self.target, name="bar") |
444 | + self.factory.makeGitRefs(other_repo, paths=["refs/heads/bug-2468"]) |
445 | |
446 | with admin_logged_in(): |
447 | getUtility(IGitRepositorySet).setDefaultRepositoryForOwner( |
448 | @@ -220,7 +222,7 @@ |
449 | [link.find(text=True) for link in table.findAll('a')]) |
450 | self.assertEndsWith( |
451 | table.find(text="bug-1234").parent['href'], |
452 | - u"/~dev/%s/+git/foo/+ref/bug-1234" % self.target_path) |
453 | + "/~dev/%s/+git/foo/+ref/bug-1234" % self.target_path) |
454 | |
455 | # Other repos are listed. |
456 | table = soup.find( |
457 | @@ -232,14 +234,14 @@ |
458 | self.assertEndsWith( |
459 | table.find( |
460 | text="lp:~dev/%s/+git/bar" % self.target_path).parent['href'], |
461 | - u"/~dev/%s/+git/bar" % self.target_path) |
462 | + "/~dev/%s/+git/bar" % self.target_path) |
463 | |
464 | # But not their branches. |
465 | self.assertNotIn('bug-2468', content) |
466 | |
467 | def test_copes_with_no_default(self): |
468 | self.factory.makeGitRepository( |
469 | - owner=self.owner, target=self.target, name=u"foo") |
470 | + owner=self.owner, target=self.target, name="foo") |
471 | |
472 | view = create_initialized_view(self.owner_target, '+git') |
473 | self.assertIs(None, view.default_git_repository) |
474 | @@ -311,9 +313,9 @@ |
475 | |
476 | def setUp(self): |
477 | super(TestProductGitListingView, self).setUp() |
478 | - self.owner = self.factory.makePerson(name=u"foowner") |
479 | - self.target = self.factory.makeProduct(name=u"foo", owner=self.owner) |
480 | - self.target_path = u"foo" |
481 | + self.owner = self.factory.makePerson(name="foowner") |
482 | + self.target = self.factory.makeProduct(name="foo", owner=self.owner) |
483 | + self.target_path = "foo" |
484 | self.branch_target = self.target |
485 | |
486 | |
487 | @@ -322,9 +324,9 @@ |
488 | |
489 | def setUp(self): |
490 | super(TestPersonProductGitListingView, self).setUp() |
491 | - self.owner = self.factory.makePerson(name=u"dev") |
492 | - self.target = self.factory.makeProduct(name=u"foo") |
493 | - self.target_path = u"foo" |
494 | + self.owner = self.factory.makePerson(name="dev") |
495 | + self.target = self.factory.makeProduct(name="foo") |
496 | + self.target_path = "foo" |
497 | self.owner_target = PersonProduct(self.owner, self.target) |
498 | self.branch_target = self.target |
499 | |
500 | @@ -334,11 +336,11 @@ |
501 | |
502 | def setUp(self): |
503 | super(TestDistributionSourcePackageGitListingView, self).setUp() |
504 | - self.owner = self.factory.makePerson(name=u"foowner") |
505 | - distro = self.factory.makeDistribution(name=u"foo", owner=self.owner) |
506 | + self.owner = self.factory.makePerson(name="foowner") |
507 | + distro = self.factory.makeDistribution(name="foo", owner=self.owner) |
508 | self.target = self.factory.makeDistributionSourcePackage( |
509 | - distribution=distro, sourcepackagename=u"bar") |
510 | - self.target_path = u"foo/+source/bar" |
511 | + distribution=distro, sourcepackagename="bar") |
512 | + self.target_path = "foo/+source/bar" |
513 | self.factory.makeDistroSeries(distribution=distro) |
514 | self.branch_target = self.target.development_version |
515 | |
516 | @@ -348,11 +350,11 @@ |
517 | |
518 | def setUp(self): |
519 | super(TestPersonDistributionSourcePackageGitListingView, self).setUp() |
520 | - self.owner = self.factory.makePerson(name=u"dev") |
521 | - distro = self.factory.makeDistribution(name=u"foo", owner=self.owner) |
522 | + self.owner = self.factory.makePerson(name="dev") |
523 | + distro = self.factory.makeDistribution(name="foo", owner=self.owner) |
524 | self.target = self.factory.makeDistributionSourcePackage( |
525 | - distribution=distro, sourcepackagename=u"bar") |
526 | - self.target_path = u"foo/+source/bar" |
527 | + distribution=distro, sourcepackagename="bar") |
528 | + self.target_path = "foo/+source/bar" |
529 | self.owner_target = PersonDistributionSourcePackage( |
530 | self.owner, self.target) |
531 | self.factory.makeDistroSeries(distribution=distro) |
532 | @@ -376,14 +378,14 @@ |
533 | |
534 | def test_rendering(self): |
535 | some_repo = self.factory.makeGitRepository( |
536 | - owner=self.owner, target=self.target, name=u"foo") |
537 | + owner=self.owner, target=self.target, name="foo") |
538 | self.factory.makeGitRefs( |
539 | some_repo, |
540 | - paths=[u"refs/heads/master", u"refs/heads/bug-1234"]) |
541 | + paths=["refs/heads/master", "refs/heads/bug-1234"]) |
542 | |
543 | other_repo = self.factory.makeGitRepository( |
544 | - owner=self.owner, target=self.target, name=u"bar") |
545 | - self.factory.makeGitRefs(other_repo, paths=[u"refs/heads/bug-2468"]) |
546 | + owner=self.owner, target=self.target, name="bar") |
547 | + self.factory.makeGitRefs(other_repo, paths=["refs/heads/bug-2468"]) |
548 | |
549 | view = create_initialized_view(self.context, '+git') |
550 | self.assertIs(None, view.default_git_repository) |
551 | |
552 | === modified file 'lib/lp/code/browser/tests/test_gitref.py' |
553 | --- lib/lp/code/browser/tests/test_gitref.py 2016-11-11 14:57:42 +0000 |
554 | +++ lib/lp/code/browser/tests/test_gitref.py 2017-10-04 01:26:22 +0000 |
555 | @@ -1,8 +1,10 @@ |
556 | -# Copyright 2015-2016 Canonical Ltd. This software is licensed under the |
557 | +# Copyright 2015-2017 Canonical Ltd. This software is licensed under the |
558 | # GNU Affero General Public License version 3 (see the file LICENSE). |
559 | |
560 | """Unit tests for GitRefView.""" |
561 | |
562 | +from __future__ import absolute_import, print_function, unicode_literals |
563 | + |
564 | __metaclass__ = type |
565 | |
566 | from datetime import datetime |
567 | @@ -52,11 +54,11 @@ |
568 | repository = self.factory.makeGitRepository( |
569 | owner=self.factory.makePerson(name="person"), |
570 | target=self.factory.makeProduct(name="target"), |
571 | - name=u"git") |
572 | + name="git") |
573 | getUtility(IGitRepositorySet).setDefaultRepositoryForOwner( |
574 | repository.owner, repository.target, repository, repository.owner) |
575 | [ref] = self.factory.makeGitRefs( |
576 | - repository=repository, paths=[u"refs/heads/master"]) |
577 | + repository=repository, paths=["refs/heads/master"]) |
578 | view = create_view(ref, "+index") |
579 | # To test the breadcrumbs we need a correct traversal stack. |
580 | view.request.traversed_objects = [repository, ref, view] |
581 | @@ -86,7 +88,7 @@ |
582 | text=re.compile(r'\smaster\s'))))) |
583 | |
584 | def test_clone_instructions(self): |
585 | - [ref] = self.factory.makeGitRefs(paths=[u"refs/heads/branch"]) |
586 | + [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) |
587 | text = self.getMainText(ref, "+index", user=ref.owner) |
588 | self.assertTextMatchesExpressionIgnoreWhitespace(r""" |
589 | git clone -b branch https://.* |
590 | @@ -102,20 +104,20 @@ |
591 | datetime(2015, 1, day + 1, tzinfo=pytz.UTC) for day in range(5)] |
592 | return [ |
593 | { |
594 | - u"sha1": unicode(hashlib.sha1(str(i)).hexdigest()), |
595 | - u"message": u"Commit %d" % i, |
596 | - u"author": { |
597 | - u"name": authors[i].display_name, |
598 | - u"email": author_emails[i], |
599 | - u"time": int((dates[i] - epoch).total_seconds()), |
600 | - }, |
601 | - u"committer": { |
602 | - u"name": authors[i].display_name, |
603 | - u"email": author_emails[i], |
604 | - u"time": int((dates[i] - epoch).total_seconds()), |
605 | - }, |
606 | - u"parents": [unicode(hashlib.sha1(str(i - 1)).hexdigest())], |
607 | - u"tree": unicode(hashlib.sha1("").hexdigest()), |
608 | + "sha1": unicode(hashlib.sha1(str(i)).hexdigest()), |
609 | + "message": "Commit %d" % i, |
610 | + "author": { |
611 | + "name": authors[i].display_name, |
612 | + "email": author_emails[i], |
613 | + "time": int((dates[i] - epoch).total_seconds()), |
614 | + }, |
615 | + "committer": { |
616 | + "name": authors[i].display_name, |
617 | + "email": author_emails[i], |
618 | + "time": int((dates[i] - epoch).total_seconds()), |
619 | + }, |
620 | + "parents": [unicode(hashlib.sha1(str(i - 1)).hexdigest())], |
621 | + "tree": unicode(hashlib.sha1("").hexdigest()), |
622 | } |
623 | for i in range(5)] |
624 | |
625 | @@ -133,7 +135,7 @@ |
626 | JobRunner([job]).runAll() |
627 | |
628 | def test_recent_commits(self): |
629 | - [ref] = self.factory.makeGitRefs(paths=[u"refs/heads/branch"]) |
630 | + [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) |
631 | log = self.makeCommitLog() |
632 | self.hosting_fixture.getLog.result = list(reversed(log)) |
633 | self.scanRef(ref, log[-1]) |
634 | @@ -153,7 +155,7 @@ |
635 | expected_urls, [detail.a["href"] for detail in details]) |
636 | |
637 | def test_recent_commits_with_merge(self): |
638 | - [ref] = self.factory.makeGitRefs(paths=[u"refs/heads/branch"]) |
639 | + [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) |
640 | log = self.makeCommitLog() |
641 | self.hosting_fixture.getLog.result = list(reversed(log)) |
642 | self.scanRef(ref, log[-1]) |
643 | @@ -179,7 +181,7 @@ |
644 | [link["href"] for link in details[5].findAll("a")]) |
645 | |
646 | def test_recent_commits_with_merge_from_deleted_ref(self): |
647 | - [ref] = self.factory.makeGitRefs(paths=[u"refs/heads/branch"]) |
648 | + [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) |
649 | log = self.makeCommitLog() |
650 | self.hosting_fixture.getLog.result = list(reversed(log)) |
651 | self.scanRef(ref, log[-1]) |
652 | @@ -206,7 +208,7 @@ |
653 | [link["href"] for link in details[5].findAll("a")]) |
654 | |
655 | def test_all_commits_link(self): |
656 | - [ref] = self.factory.makeGitRefs(paths=[u"refs/heads/branch"]) |
657 | + [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) |
658 | log = self.makeCommitLog() |
659 | self.hosting_fixture.getLog.result = list(reversed(log)) |
660 | self.scanRef(ref, log[-1]) |
661 | |
662 | === modified file 'lib/lp/code/browser/tests/test_gitrepository.py' |
663 | --- lib/lp/code/browser/tests/test_gitrepository.py 2016-11-17 23:16:12 +0000 |
664 | +++ lib/lp/code/browser/tests/test_gitrepository.py 2017-10-04 01:26:22 +0000 |
665 | @@ -1,8 +1,10 @@ |
666 | -# Copyright 2015-2016 Canonical Ltd. This software is licensed under the |
667 | +# Copyright 2015-2017 Canonical Ltd. This software is licensed under the |
668 | # GNU Affero General Public License version 3 (see the file LICENSE). |
669 | |
670 | """Unit tests for GitRepositoryView.""" |
671 | |
672 | +from __future__ import absolute_import, print_function, unicode_literals |
673 | + |
674 | __metaclass__ = type |
675 | |
676 | from datetime import datetime |
677 | @@ -327,7 +329,7 @@ |
678 | self.factory.makeAccessPolicyGrant( |
679 | policy=ap, grantee=subscriber, grantor=project.owner) |
680 | repository = self.factory.makeGitRepository( |
681 | - target=project, owner=owner, name=u"repo", |
682 | + target=project, owner=owner, name="repo", |
683 | information_type=InformationType.USERDATA) |
684 | with person_logged_in(owner): |
685 | self.factory.makeGitSubscription( |
686 | @@ -390,7 +392,7 @@ |
687 | naked_ref.author_date = now |
688 | naked_ref.committer = self.makeRevisionAuthor() |
689 | naked_ref.committer_date = now |
690 | - naked_ref.commit_message = u"something" |
691 | + naked_ref.commit_message = "something" |
692 | |
693 | recorder1, recorder2 = record_two_runs( |
694 | lambda: self.getMainText(repository, "+index"), create_ref, 10) |
695 | @@ -670,13 +672,13 @@ |
696 | # The name of a repository can be changed via the UI by an |
697 | # authorised user. |
698 | person = self.factory.makePerson() |
699 | - repository = self.factory.makeGitRepository(owner=person, name=u"foo") |
700 | + repository = self.factory.makeGitRepository(owner=person, name="foo") |
701 | browser = self.getUserBrowser( |
702 | canonical_url(repository) + "/+edit", user=person) |
703 | - browser.getControl(name="field.name").value = u"bar" |
704 | + browser.getControl(name="field.name").value = "bar" |
705 | browser.getControl("Change Git Repository").click() |
706 | with person_logged_in(person): |
707 | - self.assertEqual(u"bar", repository.name) |
708 | + self.assertEqual("bar", repository.name) |
709 | |
710 | def test_change_owner(self): |
711 | # An authorised user can change the owner to a team they're a member |
712 | @@ -762,18 +764,18 @@ |
713 | repository = self.factory.makeGitRepository(owner=person) |
714 | master, new = self.factory.makeGitRefs( |
715 | repository=repository, |
716 | - paths=[u"refs/heads/master", u"refs/heads/new"]) |
717 | - removeSecurityProxy(repository)._default_branch = u"refs/heads/master" |
718 | + paths=["refs/heads/master", "refs/heads/new"]) |
719 | + removeSecurityProxy(repository)._default_branch = "refs/heads/master" |
720 | browser = self.getUserBrowser( |
721 | canonical_url(repository) + "/+edit", user=person) |
722 | - browser.getControl(name="field.default_branch").value = u"new" |
723 | + browser.getControl(name="field.default_branch").value = "new" |
724 | browser.getControl("Change Git Repository").click() |
725 | with person_logged_in(person): |
726 | self.assertEqual( |
727 | [((repository.getInternalPath(),), |
728 | - {u"default_branch": u"refs/heads/new"})], |
729 | + {"default_branch": "refs/heads/new"})], |
730 | hosting_fixture.setProperties.calls) |
731 | - self.assertEqual(u"refs/heads/new", repository.default_branch) |
732 | + self.assertEqual("refs/heads/new", repository.default_branch) |
733 | |
734 | def test_change_default_branch_nonexistent(self): |
735 | # Trying to change the default branch to one that doesn't exist |
736 | @@ -781,8 +783,8 @@ |
737 | person = self.factory.makePerson() |
738 | repository = self.factory.makeGitRepository(owner=person) |
739 | [master] = self.factory.makeGitRefs( |
740 | - repository=repository, paths=[u"refs/heads/master"]) |
741 | - removeSecurityProxy(repository)._default_branch = u"refs/heads/master" |
742 | + repository=repository, paths=["refs/heads/master"]) |
743 | + removeSecurityProxy(repository)._default_branch = "refs/heads/master" |
744 | form = { |
745 | "field.default_branch": "refs/heads/new", |
746 | "field.actions.change": "Change Git Repository", |
747 | @@ -794,7 +796,7 @@ |
748 | ["This repository does not contain a reference named " |
749 | "'refs/heads/new'."], |
750 | view.errors) |
751 | - self.assertEqual(u"refs/heads/master", repository.default_branch) |
752 | + self.assertEqual("refs/heads/master", repository.default_branch) |
753 | |
754 | |
755 | class TestGitRepositoryEditViewInformationTypes(TestCaseWithFactory): |
756 | @@ -869,7 +871,7 @@ |
757 | layer = DatabaseFunctionalLayer |
758 | |
759 | def test_render(self): |
760 | - diff = u"A fake diff\n" |
761 | + diff = "A fake diff\n" |
762 | hosting_fixture = self.useFixture(GitHostingFixture( |
763 | diff={"patch": diff})) |
764 | person = self.factory.makePerson() |
765 | @@ -891,7 +893,7 @@ |
766 | def test_security(self): |
767 | # A user who can see a private repository can fetch diffs from it, |
768 | # but other users cannot. |
769 | - diff = u"A fake diff\n" |
770 | + diff = "A fake diff\n" |
771 | self.useFixture(GitHostingFixture(diff={"patch": diff})) |
772 | person = self.factory.makePerson() |
773 | project = self.factory.makeProduct( |
774 | |
775 | === modified file 'lib/lp/code/browser/tests/test_gitsubscription.py' |
776 | --- lib/lp/code/browser/tests/test_gitsubscription.py 2016-11-09 17:18:21 +0000 |
777 | +++ lib/lp/code/browser/tests/test_gitsubscription.py 2017-10-04 01:26:22 +0000 |
778 | @@ -1,8 +1,10 @@ |
779 | -# Copyright 2015-2016 Canonical Ltd. This software is licensed under the |
780 | +# Copyright 2015-2017 Canonical Ltd. This software is licensed under the |
781 | # GNU Affero General Public License version 3 (see the file LICENSE). |
782 | |
783 | """Unit tests for GitSubscriptions.""" |
784 | |
785 | +from __future__ import absolute_import, print_function, unicode_literals |
786 | + |
787 | __metaclass__ = type |
788 | |
789 | from urllib import urlencode |
790 | |
791 | === modified file 'lib/lp/code/browser/tests/test_product.py' |
792 | --- lib/lp/code/browser/tests/test_product.py 2015-06-04 08:50:04 +0000 |
793 | +++ lib/lp/code/browser/tests/test_product.py 2017-10-04 01:26:22 +0000 |
794 | @@ -1,8 +1,10 @@ |
795 | -# Copyright 2009-2015 Canonical Ltd. This software is licensed under the |
796 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
797 | # GNU Affero General Public License version 3 (see the file LICENSE). |
798 | |
799 | """Tests for the product view classes and templates.""" |
800 | |
801 | +from __future__ import absolute_import, print_function, unicode_literals |
802 | + |
803 | __metaclass__ = type |
804 | |
805 | from datetime import ( |
806 | |
807 | === modified file 'lib/lp/code/browser/tests/test_revisionauthor.py' |
808 | --- lib/lp/code/browser/tests/test_revisionauthor.py 2012-01-01 02:58:52 +0000 |
809 | +++ lib/lp/code/browser/tests/test_revisionauthor.py 2017-10-04 01:26:22 +0000 |
810 | @@ -1,8 +1,10 @@ |
811 | -# Copyright 2011 Canonical Ltd. This software is licensed under the |
812 | +# Copyright 2011-2017 Canonical Ltd. This software is licensed under the |
813 | # GNU Affero General Public License version 3 (see the file LICENSE). |
814 | |
815 | """Tests related to `RevisionAuthor`.""" |
816 | |
817 | +from __future__ import absolute_import, print_function, unicode_literals |
818 | + |
819 | __metaclass__ = type |
820 | |
821 | from lp.app.browser.tales import ( |
822 | |
823 | === modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py' |
824 | --- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2017-06-16 10:29:14 +0000 |
825 | +++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2017-10-04 01:26:22 +0000 |
826 | @@ -3,9 +3,10 @@ |
827 | |
828 | """Tests for the source package recipe view classes and templates.""" |
829 | |
830 | +from __future__ import absolute_import, print_function, unicode_literals |
831 | + |
832 | __metaclass__ = type |
833 | |
834 | - |
835 | from datetime import ( |
836 | datetime, |
837 | timedelta, |
838 | @@ -91,7 +92,7 @@ |
839 | def test_canonical_url(self): |
840 | owner = self.factory.makePerson(name='recipe-owner') |
841 | recipe = self.factory.makeSourcePackageRecipe( |
842 | - owner=owner, name=u'recipe-name') |
843 | + owner=owner, name='recipe-name') |
844 | self.assertEqual( |
845 | 'http://code.launchpad.dev/~recipe-owner/+recipe/recipe-name', |
846 | canonical_url(recipe)) |
847 | @@ -261,10 +262,10 @@ |
848 | """Create and return a specific recipe.""" |
849 | chocolate = self.factory.makeProduct(name='chocolate') |
850 | cake_branch = self.makeBranch( |
851 | - owner=self.chef, name=u'cake', target=chocolate) |
852 | + owner=self.chef, name='cake', target=chocolate) |
853 | return self.factory.makeSourcePackageRecipe( |
854 | - owner=self.chef, distroseries=self.squirrel, name=u'cake_recipe', |
855 | - description=u'This recipe builds a foo for distro bar, with my' |
856 | + owner=self.chef, distroseries=self.squirrel, name='cake_recipe', |
857 | + description='This recipe builds a foo for distro bar, with my' |
858 | ' Secret Squirrel changes.', branches=[cake_branch], |
859 | daily_build_archive=self.ppa, **kwargs) |
860 | |
861 | @@ -277,8 +278,7 @@ |
862 | # If the initial name exists, a generator is used to find an unused |
863 | # name by appending a numbered suffix on the end. |
864 | owner = self.factory.makePerson() |
865 | - self.factory.makeSourcePackageRecipe( |
866 | - owner=owner, name=u'widget-daily') |
867 | + self.factory.makeSourcePackageRecipe(owner=owner, name='widget-daily') |
868 | widget = self.factory.makeProduct(name='widget') |
869 | branch = self.makeBranch(target=widget) |
870 | with person_logged_in(owner): |
871 | @@ -380,7 +380,7 @@ |
872 | # not helpful. |
873 | owner = self.factory.makePerson() |
874 | repository = self.factory.makeGitRepository( |
875 | - owner=owner, target=owner, name=u'widget') |
876 | + owner=owner, target=owner, name='widget') |
877 | with person_logged_in(repository.owner): |
878 | view = create_initialized_view(repository, '+new-recipe') |
879 | self.assertThat('widget-daily', Equals(view.initial_values['name'])) |
880 | @@ -395,7 +395,7 @@ |
881 | product = self.factory.makeProduct( |
882 | name='ratatouille', displayname='Ratatouille') |
883 | branch = self.makeBranch( |
884 | - owner=self.chef, target=product, name=u'veggies') |
885 | + owner=self.chef, target=product, name='veggies') |
886 | |
887 | browser = self.getViewBrowser(branch, no_login=True) |
888 | self.assertRaises( |
889 | @@ -461,7 +461,7 @@ |
890 | browser.getControl('Create Recipe').click() |
891 | |
892 | login(ANONYMOUS) |
893 | - recipe = team.getRecipe(u'daily') |
894 | + recipe = team.getRecipe('daily') |
895 | self.assertEqual(team, recipe.owner) |
896 | self.assertEqual('daily', recipe.name) |
897 | |
898 | @@ -498,7 +498,7 @@ |
899 | product = self.factory.makeProduct( |
900 | name='ratatouille', displayname='Ratatouille') |
901 | branch = self.makeBranch( |
902 | - owner=self.chef, target=product, name=u'veggies') |
903 | + owner=self.chef, target=product, name='veggies') |
904 | browser = self.getViewBrowser(branch, '+new-recipe', user=self.chef) |
905 | browser.getControl('Description').value = 'Make some food!' |
906 | browser.getControl('Recipe text').value = ( |
907 | @@ -513,7 +513,7 @@ |
908 | product = self.factory.makeProduct( |
909 | name='ratatouille', displayname='Ratatouille') |
910 | branch = self.makeBranch( |
911 | - owner=self.chef, target=product, name=u'veggies') |
912 | + owner=self.chef, target=product, name='veggies') |
913 | browser = self.getViewBrowser(branch, '+new-recipe', user=self.chef) |
914 | browser.getControl(name='field.name').value = 'daily' |
915 | browser.getControl('Description').value = 'Make some food!' |
916 | @@ -524,8 +524,8 @@ |
917 | def test_create_recipe_usage(self): |
918 | # The error for a recipe with invalid instruction parameters should |
919 | # include instruction usage. |
920 | - branch = self.makeBranch(name=u'veggies') |
921 | - self.makeBranch(name=u'packaging') |
922 | + branch = self.makeBranch(name='veggies') |
923 | + self.makeBranch(name='packaging') |
924 | |
925 | browser = self.createRecipe( |
926 | self.getMinimalRecipeText(branch) + "merge\n", branch=branch) |
927 | @@ -564,7 +564,7 @@ |
928 | product = self.factory.makeProduct( |
929 | name='ratatouille', displayname='Ratatouille') |
930 | branch = self.makeBranch( |
931 | - owner=self.chef, target=product, name=u'veggies') |
932 | + owner=self.chef, target=product, name='veggies') |
933 | recipe = self.getMinimalRecipeText(branch) |
934 | recipe += 'nest packaging foo debian' |
935 | browser = self.createRecipe(recipe, branch) |
936 | @@ -578,7 +578,7 @@ |
937 | product = self.factory.makeProduct( |
938 | name='ratatouille', displayname='Ratatouille') |
939 | branch = self.makeBranch( |
940 | - owner=self.chef, target=product, name=u'veggies') |
941 | + owner=self.chef, target=product, name='veggies') |
942 | |
943 | with recipe_parser_newest_version(145.115): |
944 | recipe = re.sub( |
945 | @@ -599,7 +599,7 @@ |
946 | product = self.factory.makeProduct( |
947 | name='ratatouille', displayname='Ratatouille') |
948 | branch = self.makeBranch( |
949 | - owner=self.chef, target=product, name=u'veggies') |
950 | + owner=self.chef, target=product, name='veggies') |
951 | |
952 | # A new recipe can be created from the branch page. |
953 | browser = self.getUserBrowser(canonical_url(branch), user=self.chef) |
954 | @@ -859,7 +859,7 @@ |
955 | product = self.factory.makeProduct( |
956 | name='ratatouille', displayname='Ratatouille') |
957 | repository = self.factory.makeGitRepository( |
958 | - owner=self.chef, target=product, name=u'veggies') |
959 | + owner=self.chef, target=product, name='veggies') |
960 | self.factory.makeDistributionSourcePackage( |
961 | sourcepackagename='ratatouille') |
962 | return repository |
963 | @@ -877,12 +877,12 @@ |
964 | product = self.factory.makeProduct( |
965 | name='ratatouille', displayname='Ratatouille') |
966 | veggie_branch = self.makeBranch( |
967 | - owner=self.chef, target=product, name=u'veggies') |
968 | + owner=self.chef, target=product, name='veggies') |
969 | meat_branch = self.makeBranch( |
970 | - owner=self.chef, target=product, name=u'meat') |
971 | + owner=self.chef, target=product, name='meat') |
972 | recipe = self.factory.makeSourcePackageRecipe( |
973 | owner=self.chef, registrant=self.chef, |
974 | - name=u'things', description=u'This is a recipe', |
975 | + name='things', description='This is a recipe', |
976 | distroseries=self.squirrel, branches=[veggie_branch], |
977 | daily_build_archive=self.ppa) |
978 | self.factory.makeArchive( |
979 | @@ -921,7 +921,7 @@ |
980 | view = SourcePackageRecipeEditView(recipe, LaunchpadTestRequest()) |
981 | view.initialize() |
982 | view.request_action.success({ |
983 | - 'name': u'fings', |
984 | + 'name': 'fings', |
985 | 'recipe_text': recipe.recipe_text, |
986 | 'distroseries': recipe.distroseries}) |
987 | self.assertSqlAttributeEqualsDate( |
988 | @@ -934,12 +934,12 @@ |
989 | product = self.factory.makeProduct( |
990 | name='ratatouille', displayname='Ratatouille') |
991 | veggie_branch = self.makeBranch( |
992 | - owner=self.chef, target=product, name=u'veggies') |
993 | + owner=self.chef, target=product, name='veggies') |
994 | meat_branch = self.makeBranch( |
995 | - owner=self.chef, target=product, name=u'meat') |
996 | + owner=self.chef, target=product, name='meat') |
997 | recipe = self.factory.makeSourcePackageRecipe( |
998 | owner=self.chef, registrant=self.chef, |
999 | - name=u'things', description=u'This is a recipe', |
1000 | + name='things', description='This is a recipe', |
1001 | distroseries=self.squirrel, branches=[veggie_branch], |
1002 | daily_build_archive=self.ppa) |
1003 | |
1004 | @@ -979,10 +979,10 @@ |
1005 | product = self.factory.makeProduct( |
1006 | name='ratatouille', displayname='Ratatouille') |
1007 | veggie_branch = self.makeBranch( |
1008 | - owner=self.chef, target=product, name=u'veggies') |
1009 | + owner=self.chef, target=product, name='veggies') |
1010 | recipe = self.factory.makeSourcePackageRecipe( |
1011 | owner=self.chef, registrant=self.chef, |
1012 | - name=u'things', description=u'This is a recipe', |
1013 | + name='things', description='This is a recipe', |
1014 | distroseries=self.squirrel, branches=[veggie_branch]) |
1015 | |
1016 | browser = self.getUserBrowser(canonical_url(recipe), user=self.chef) |
1017 | @@ -1004,10 +1004,10 @@ |
1018 | product = self.factory.makeProduct( |
1019 | name='ratatouille', displayname='Ratatouille') |
1020 | veggie_branch = self.makeBranch( |
1021 | - owner=self.chef, target=product, name=u'veggies') |
1022 | + owner=self.chef, target=product, name='veggies') |
1023 | recipe = self.factory.makeSourcePackageRecipe( |
1024 | owner=self.chef, registrant=self.chef, |
1025 | - name=u'things', description=u'This is a recipe', |
1026 | + name='things', description='This is a recipe', |
1027 | distroseries=self.squirrel, branches=[veggie_branch]) |
1028 | |
1029 | new_recipe_text = re.sub( |
1030 | @@ -1031,16 +1031,16 @@ |
1031 | product = self.factory.makeProduct( |
1032 | name='ratatouille', displayname='Ratatouille') |
1033 | veggie_branch = self.makeBranch( |
1034 | - owner=self.chef, target=product, name=u'veggies') |
1035 | + owner=self.chef, target=product, name='veggies') |
1036 | meat_branch = self.makeBranch( |
1037 | - owner=self.chef, target=product, name=u'meat') |
1038 | + owner=self.chef, target=product, name='meat') |
1039 | recipe = self.factory.makeSourcePackageRecipe( |
1040 | owner=self.chef, registrant=self.chef, |
1041 | - name=u'things', description=u'This is a recipe', |
1042 | + name='things', description='This is a recipe', |
1043 | distroseries=self.squirrel, branches=[veggie_branch]) |
1044 | self.factory.makeSourcePackageRecipe( |
1045 | owner=self.chef, registrant=self.chef, |
1046 | - name=u'fings', description=u'This is a recipe', |
1047 | + name='fings', description='This is a recipe', |
1048 | distroseries=self.squirrel, branches=[veggie_branch]) |
1049 | |
1050 | recipe_text = self.getMinimalRecipeText(meat_branch) |
1051 | @@ -1717,7 +1717,7 @@ |
1052 | owner=self.user) |
1053 | branch = self.makeBranch() |
1054 | recipe = self.factory.makeSourcePackageRecipe( |
1055 | - owner=self.user, name=u'my-recipe', branches=[branch]) |
1056 | + owner=self.user, name='my-recipe', branches=[branch]) |
1057 | distro_series = self.factory.makeDistroSeries( |
1058 | name='squirrel', distribution=archive.distribution) |
1059 | removeSecurityProxy(distro_series).nominatedarchindep = ( |
1060 | @@ -1999,7 +1999,7 @@ |
1061 | recipe = self.factory.makeSourcePackageRecipe(recipe=recipe_text) |
1062 | naked_data = removeSecurityProxy(recipe)._recipe_data |
1063 | nest_instruction = list(naked_data.instructions)[0] |
1064 | - nest_instruction.directory = u'.' |
1065 | + nest_instruction.directory = '.' |
1066 | return recipe |
1067 | |
1068 | def test_recipe_is_broken(self): |
1069 | |
1070 | === modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py' |
1071 | --- lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py 2017-05-08 11:38:20 +0000 |
1072 | +++ lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py 2017-10-04 01:26:22 +0000 |
1073 | @@ -1,7 +1,10 @@ |
1074 | # Copyright 2010-2017 Canonical Ltd. This software is licensed under the |
1075 | # GNU Affero General Public License version 3 (see the file LICENSE). |
1076 | + |
1077 | """Tests for the source package recipe view classes and templates.""" |
1078 | |
1079 | +from __future__ import absolute_import, print_function, unicode_literals |
1080 | + |
1081 | __metaclass__ = type |
1082 | |
1083 | from fixtures import FakeLogger |
1084 | @@ -77,8 +80,8 @@ |
1085 | cake_branch = self.factory.makeProductBranch( |
1086 | owner=self.chef, name='cake', product=chocolate) |
1087 | recipe = self.factory.makeSourcePackageRecipe( |
1088 | - owner=self.chef, distroseries=self.squirrel, name=u'cake_recipe', |
1089 | - description=u'This recipe builds a foo for disto bar, with my' |
1090 | + owner=self.chef, distroseries=self.squirrel, name='cake_recipe', |
1091 | + description='This recipe builds a foo for distro bar, with my' |
1092 | ' Secret Squirrel changes.', branches=[cake_branch], |
1093 | daily_build_archive=self.ppa) |
1094 | build = self.factory.makeSourcePackageRecipeBuild( |
1095 | |
1096 | === modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipelisting.py' |
1097 | --- lib/lp/code/browser/tests/test_sourcepackagerecipelisting.py 2015-10-19 10:56:16 +0000 |
1098 | +++ lib/lp/code/browser/tests/test_sourcepackagerecipelisting.py 2017-10-04 01:26:22 +0000 |
1099 | @@ -1,11 +1,12 @@ |
1100 | -# Copyright 2010-2015 Canonical Ltd. This software is licensed under the |
1101 | +# Copyright 2010-2017 Canonical Ltd. This software is licensed under the |
1102 | # GNU Affero General Public License version 3 (see the file LICENSE). |
1103 | |
1104 | """Tests for sourcepackagerecipe listings.""" |
1105 | |
1106 | +from __future__ import absolute_import, print_function, unicode_literals |
1107 | + |
1108 | __metaclass__ = type |
1109 | |
1110 | - |
1111 | from lp.testing import ( |
1112 | BrowserTestCase, |
1113 | person_logged_in, |
1114 | |
1115 | === modified file 'lib/lp/code/browser/tests/test_tales.py' |
1116 | --- lib/lp/code/browser/tests/test_tales.py 2016-01-12 15:27:50 +0000 |
1117 | +++ lib/lp/code/browser/tests/test_tales.py 2017-10-04 01:26:22 +0000 |
1118 | @@ -1,8 +1,10 @@ |
1119 | -# Copyright 2009-2015 Canonical Ltd. This software is licensed under the |
1120 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
1121 | # GNU Affero General Public License version 3 (see the file LICENSE). |
1122 | |
1123 | """Tests for the tales formatters.""" |
1124 | |
1125 | +from __future__ import absolute_import, print_function, unicode_literals |
1126 | + |
1127 | __metaclass__ = type |
1128 | |
1129 | from difflib import unified_diff |
1130 | @@ -41,7 +43,7 @@ |
1131 | else: |
1132 | content = '' |
1133 | preview = bmp.updatePreviewDiff( |
1134 | - content, u'rev-a', u'rev-b', conflicts=conflicts) |
1135 | + content, 'rev-a', 'rev-b', conflicts=conflicts) |
1136 | bmp.source_branch.last_scanned_id = preview.source_revision_id |
1137 | bmp.target_branch.last_scanned_id = preview.target_revision_id |
1138 | # Update the values directly sidestepping the security. |
1139 | @@ -68,13 +70,13 @@ |
1140 | def test_creation_method(self): |
1141 | # Just confirm that our helpers do what they say. |
1142 | preview = self._createPreviewDiff( |
1143 | - 12, 45, 23, u'conflicts', {'filename': (3, 2)}) |
1144 | + 12, 45, 23, 'conflicts', {'filename': (3, 2)}) |
1145 | self.assertEqual(12, preview.diff_lines_count) |
1146 | self.assertEqual(45, preview.added_lines_count) |
1147 | self.assertEqual(23, preview.removed_lines_count) |
1148 | self.assertEqual(False, preview.stale) |
1149 | self.assertEqual(True, self._createStalePreviewDiff().stale) |
1150 | - self.assertEqual(u'conflicts', preview.conflicts) |
1151 | + self.assertEqual('conflicts', preview.conflicts) |
1152 | self.assertEqual({'filename': (3, 2)}, preview.diffstat) |
1153 | |
1154 | def test_fmt_no_diff(self): |
1155 | @@ -151,7 +153,7 @@ |
1156 | |
1157 | def test_fmt_simple_conflicts(self): |
1158 | # Conflicts are indicated using text in the link. |
1159 | - preview = self._createPreviewDiff(10, 2, 3, u'conflicts') |
1160 | + preview = self._createPreviewDiff(10, 2, 3, 'conflicts') |
1161 | self.assertEqual( |
1162 | '<a href="%s/+files/preview.diff" class="diff-link">' |
1163 | '10 lines (+2/-3) (has conflicts)</a>' |
1164 | @@ -188,7 +190,7 @@ |
1165 | diffstat = dict( |
1166 | (self.factory.getUniqueString(), (2, 3)) for x in range(23)) |
1167 | preview = self._createStalePreviewDiff( |
1168 | - 500, 89, 340, u'conflicts', diffstat=diffstat) |
1169 | + 500, 89, 340, 'conflicts', diffstat=diffstat) |
1170 | expected_diffstat = '<br/>'.join( |
1171 | '%s (+2/-3)' % path for path in sorted(diffstat)) |
1172 | self.assertEqual( |
1173 | |
1174 | === modified file 'lib/lp/code/browser/tests/test_vcslisting.py' |
1175 | --- lib/lp/code/browser/tests/test_vcslisting.py 2015-06-12 06:34:19 +0000 |
1176 | +++ lib/lp/code/browser/tests/test_vcslisting.py 2017-10-04 01:26:22 +0000 |
1177 | @@ -1,8 +1,10 @@ |
1178 | -# Copyright 2009-2015 Canonical Ltd. This software is licensed under the |
1179 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
1180 | # GNU Affero General Public License version 3 (see the file LICENSE). |
1181 | |
1182 | """Tests for the product view classes and templates.""" |
1183 | |
1184 | +from __future__ import absolute_import, print_function, unicode_literals |
1185 | + |
1186 | __metaclass__ = type |
1187 | |
1188 | from zope.publisher.interfaces import NotFound |
1189 | |
1190 | === modified file 'lib/lp/code/browser/tests/test_views.py' |
1191 | --- lib/lp/code/browser/tests/test_views.py 2011-12-28 17:03:06 +0000 |
1192 | +++ lib/lp/code/browser/tests/test_views.py 2017-10-04 01:26:22 +0000 |
1193 | @@ -1,9 +1,9 @@ |
1194 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
1195 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
1196 | # GNU Affero General Public License version 3 (see the file LICENSE). |
1197 | |
1198 | -""" |
1199 | -Run the view tests. |
1200 | -""" |
1201 | +"""Run the view tests.""" |
1202 | + |
1203 | +from __future__ import absolute_import, print_function, unicode_literals |
1204 | |
1205 | import logging |
1206 | import os |