Merge lp:~cjwatson/launchpad/code-bzr-tests-future-imports into lp:launchpad
- code-bzr-tests-future-imports
- Merge into devel
Proposed by
Colin Watson
Status: | Merged |
---|---|
Merged at revision: | 18480 |
Proposed branch: | lp:~cjwatson/launchpad/code-bzr-tests-future-imports |
Merge into: | lp:launchpad |
Prerequisite: | lp:~cjwatson/launchpad/code-git-tests-future-imports |
Diff against target: |
907 lines (+181/-170) 6 files modified
lib/lp/code/model/tests/test_branch.py (+5/-4) lib/lp/code/model/tests/test_branchjob.py (+74/-71) lib/lp/code/model/tests/test_diff.py (+28/-27) lib/lp/code/model/tests/test_revision.py (+5/-3) lib/lp/code/tests/test_bzr.py (+28/-26) lib/lp/code/tests/test_directbranchcommit.py (+41/-39) |
To merge this branch: | bzr merge lp:~cjwatson/launchpad/code-bzr-tests-future-imports |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+331762@code.launchpad.net |
Commit message
Convert closely-
Description of the change
We need to take some care to keep revision IDs and file texts as bytes.
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) : | # |
review:
Approve
(code)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/lp/code/model/tests/test_branch.py' |
2 | --- lib/lp/code/model/tests/test_branch.py 2016-10-15 02:28:10 +0000 |
3 | +++ lib/lp/code/model/tests/test_branch.py 2017-10-04 01:52:47 +0000 |
4 | @@ -1,8 +1,9 @@ |
5 | -# Copyright 2009-2016 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 Branches.""" |
10 | |
11 | +from __future__ import absolute_import, print_function, unicode_literals |
12 | |
13 | __metaclass__ = type |
14 | |
15 | @@ -335,7 +336,7 @@ |
16 | self.useBzrBranches() |
17 | db_branch, bzr_tree = self.create_branch_and_tree() |
18 | bzr_tree.commit( |
19 | - 'First commit', rev_id='rev1', committer='me@example.org') |
20 | + 'First commit', rev_id=b'rev1', committer='me@example.org') |
21 | with person_logged_in(db_branch.owner): |
22 | db_branch.branchChanged(None, 'rev1', None, None, None) |
23 | with block_on_job(): |
24 | @@ -347,7 +348,7 @@ |
25 | self.useBzrBranches() |
26 | db_branch, bzr_tree = self.create_branch_and_tree() |
27 | bzr_tree.commit( |
28 | - 'First commit', rev_id='rev1', committer='me@example.org') |
29 | + 'First commit', rev_id=b'rev1', committer='me@example.org') |
30 | with person_logged_in(db_branch.owner): |
31 | db_branch.branchChanged(None, 'rev1', None, None, None) |
32 | with monitor_celery() as responses: |
33 | @@ -1941,7 +1942,7 @@ |
34 | |
35 | def test_attributeAssignment(self): |
36 | """Smoke test to make sure the assignments are there.""" |
37 | - commit_message = u'Some commit message' |
38 | + commit_message = 'Some commit message' |
39 | proposal = self.source.addLandingTarget( |
40 | self.user, self.target, self.prerequisite, |
41 | commit_message=commit_message) |
42 | |
43 | === modified file 'lib/lp/code/model/tests/test_branchjob.py' |
44 | --- lib/lp/code/model/tests/test_branchjob.py 2016-02-04 12:21:45 +0000 |
45 | +++ lib/lp/code/model/tests/test_branchjob.py 2017-10-04 01:52:47 +0000 |
46 | @@ -1,8 +1,10 @@ |
47 | -# Copyright 2009-2015 Canonical Ltd. This software is licensed under the |
48 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
49 | # GNU Affero General Public License version 3 (see the file LICENSE). |
50 | |
51 | """Tests for BranchJobs.""" |
52 | |
53 | +from __future__ import absolute_import, print_function, unicode_literals |
54 | + |
55 | __metaclass__ = type |
56 | |
57 | import datetime |
58 | @@ -147,9 +149,9 @@ |
59 | # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is |
60 | # required to generate the revision-id. |
61 | with override_environ(BZR_EMAIL='me@example.com'): |
62 | - bzr_tree.commit('First commit', rev_id='rev1') |
63 | - bzr_tree.commit('Second commit', rev_id='rev2') |
64 | - bzr_tree.commit('Third commit', rev_id='rev3') |
65 | + bzr_tree.commit('First commit', rev_id=b'rev1') |
66 | + bzr_tree.commit('Second commit', rev_id=b'rev2') |
67 | + bzr_tree.commit('Third commit', rev_id=b'rev3') |
68 | LaunchpadZopelessLayer.commit() |
69 | |
70 | job = BranchScanJob.create(db_branch) |
71 | @@ -158,8 +160,8 @@ |
72 | |
73 | self.assertEqual(db_branch.revision_count, 3) |
74 | |
75 | - bzr_tree.commit('Fourth commit', rev_id='rev4') |
76 | - bzr_tree.commit('Fifth commit', rev_id='rev5') |
77 | + bzr_tree.commit('Fourth commit', rev_id=b'rev4') |
78 | + bzr_tree.commit('Fifth commit', rev_id=b'rev5') |
79 | |
80 | job = BranchScanJob.create(db_branch) |
81 | with dbuser("branchscanner"): |
82 | @@ -175,7 +177,7 @@ |
83 | # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is |
84 | # required to generate the revision-id. |
85 | with override_environ(BZR_EMAIL='me@example.com'): |
86 | - bzr_tree.commit('First commit', rev_id='rev1') |
87 | + bzr_tree.commit('First commit', rev_id=b'rev1') |
88 | LaunchpadZopelessLayer.commit() |
89 | |
90 | expected_message = ( |
91 | @@ -194,10 +196,10 @@ |
92 | product = self.factory.makeProduct() |
93 | private_bug = self.factory.makeBug( |
94 | target=product, information_type=InformationType.USERDATA) |
95 | - bug_line = 'https://launchpad.net/bugs/%s fixed' % private_bug.id |
96 | + bug_line = b'https://launchpad.net/bugs/%s fixed' % private_bug.id |
97 | with override_environ(BZR_EMAIL='me@example.com'): |
98 | bzr_tree.commit( |
99 | - 'First commit', rev_id='rev1', revprops={'bugs': bug_line}) |
100 | + 'First commit', rev_id=b'rev1', revprops={b'bugs': bug_line}) |
101 | job = BranchScanJob.create(db_branch) |
102 | with dbuser("branchscanner"): |
103 | job.run() |
104 | @@ -435,12 +437,12 @@ |
105 | # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is |
106 | # required to generate the revision-id. |
107 | with override_environ(BZR_EMAIL='me@example.com'): |
108 | - tree.commit('rev1', rev_id='rev1') |
109 | - tree.commit('rev2', rev_id='rev2') |
110 | - tree.commit('rev3', rev_id='rev3') |
111 | + tree.commit('rev1', rev_id=b'rev1') |
112 | + tree.commit('rev2', rev_id=b'rev2') |
113 | + tree.commit('rev3', rev_id=b'rev3') |
114 | switch_dbuser('branchscanner') |
115 | self.updateDBRevisions( |
116 | - branch, tree.branch, ['rev1', 'rev2', 'rev3']) |
117 | + branch, tree.branch, [b'rev1', b'rev2', b'rev3']) |
118 | finally: |
119 | tree.unlock() |
120 | return branch, tree |
121 | @@ -459,18 +461,18 @@ |
122 | """iterAddedMainline drops non-mainline revisions.""" |
123 | self.useBzrBranches(direct_database=True) |
124 | branch, tree = self.create3CommitsBranch() |
125 | - tree.pull(tree.branch, overwrite=True, stop_revision='rev2') |
126 | - tree.add_parent_tree_id('rev3') |
127 | + tree.pull(tree.branch, overwrite=True, stop_revision=b'rev2') |
128 | + tree.add_parent_tree_id(b'rev3') |
129 | # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is |
130 | # required to generate the revision-id. |
131 | with override_environ(BZR_EMAIL='me@example.com'): |
132 | - tree.commit('rev3a', rev_id='rev3a') |
133 | - self.updateDBRevisions(branch, tree.branch, ['rev3', 'rev3a']) |
134 | + tree.commit('rev3a', rev_id=b'rev3a') |
135 | + self.updateDBRevisions(branch, tree.branch, [b'rev3', b'rev3a']) |
136 | job = RevisionsAddedJob.create(branch, 'rev1', 'rev3', '') |
137 | job.bzr_branch.lock_read() |
138 | self.addCleanup(job.bzr_branch.unlock) |
139 | out = [x.revision_id for x, y in job.iterAddedMainline()] |
140 | - self.assertEqual(['rev2'], out) |
141 | + self.assertEqual([b'rev2'], out) |
142 | |
143 | def test_iterAddedMainline_order(self): |
144 | """iterAddedMainline iterates in commit order.""" |
145 | @@ -481,9 +483,9 @@ |
146 | self.addCleanup(job.bzr_branch.unlock) |
147 | # Since we've gone from rev1 to rev3, we've added rev2 and rev3. |
148 | [(rev2, revno2), (rev3, revno3)] = list(job.iterAddedMainline()) |
149 | - self.assertEqual('rev2', rev2.revision_id) |
150 | + self.assertEqual(b'rev2', rev2.revision_id) |
151 | self.assertEqual(2, revno2) |
152 | - self.assertEqual('rev3', rev3.revision_id) |
153 | + self.assertEqual(b'rev3', rev3.revision_id) |
154 | self.assertEqual(3, revno3) |
155 | |
156 | def makeBranchWithCommit(self): |
157 | @@ -506,7 +508,7 @@ |
158 | # required to generate the revision-id. |
159 | with override_environ(BZR_EMAIL='me@example.com'): |
160 | tree.commit( |
161 | - 'rev1', rev_id='rev1', timestamp=1000, timezone=0, |
162 | + 'rev1', rev_id=b'rev1', timestamp=1000, timezone=0, |
163 | committer='J. Random Hacker <jrandom@example.org>') |
164 | return branch, tree |
165 | |
166 | @@ -526,16 +528,16 @@ |
167 | with override_environ(BZR_EMAIL='me@example.com'): |
168 | tree.commit('rev1') |
169 | tree2 = tree.bzrdir.sprout('tree2').open_workingtree() |
170 | - tree2.commit('rev2a', rev_id='rev2a-id', committer='foo@') |
171 | - tree2.commit('rev3', rev_id='rev3-id', |
172 | + tree2.commit('rev2a', rev_id=b'rev2a-id', committer='foo@') |
173 | + tree2.commit('rev3', rev_id=b'rev3-id', |
174 | authors=['bar@', 'baz@blaine.com']) |
175 | tree.merge_from_branch(tree2.branch) |
176 | tree3 = tree.bzrdir.sprout('tree3').open_workingtree() |
177 | - tree3.commit('rev2b', rev_id='rev2b-id', committer='qux@') |
178 | + tree3.commit('rev2b', rev_id=b'rev2b-id', committer='qux@') |
179 | tree.merge_from_branch(tree3.branch, force=True) |
180 | if include_ghost: |
181 | - tree.add_parent_tree_id('rev2c-id') |
182 | - tree.commit('rev2d', rev_id='rev2d-id', timestamp=1000, |
183 | + tree.add_parent_tree_id(b'rev2c-id') |
184 | + tree.commit('rev2d', rev_id=b'rev2d-id', timestamp=1000, |
185 | timezone=0, authors=authors, |
186 | committer='J. Random Hacker <jrandom@example.org>') |
187 | return RevisionsAddedJob.create(branch, 'rev2d-id', 'rev2d-id', '') |
188 | @@ -546,8 +548,9 @@ |
189 | job.bzr_branch.lock_write() |
190 | graph = job.bzr_branch.repository.get_graph() |
191 | self.addCleanup(job.bzr_branch.unlock) |
192 | - self.assertEqual(set(['rev2a-id', 'rev3-id', 'rev2b-id', 'rev2c-id']), |
193 | - job.getMergedRevisionIDs('rev2d-id', graph)) |
194 | + self.assertEqual( |
195 | + set([b'rev2a-id', b'rev3-id', b'rev2b-id', b'rev2c-id']), |
196 | + job.getMergedRevisionIDs('rev2d-id', graph)) |
197 | |
198 | def test_findRelatedBMP(self): |
199 | """The related branch merge proposals can be identified.""" |
200 | @@ -591,7 +594,7 @@ |
201 | job.bzr_branch.lock_write() |
202 | self.addCleanup(job.bzr_branch.unlock) |
203 | graph = job.bzr_branch.repository.get_graph() |
204 | - revision_ids = ['rev2a-id', 'rev3-id', 'rev2b-id'] |
205 | + revision_ids = [b'rev2a-id', b'rev3-id', b'rev2b-id'] |
206 | self.assertEqual(set(['foo@', 'bar@', 'baz@blaine.com', 'qux@']), |
207 | job.getAuthors(revision_ids, graph)) |
208 | |
209 | @@ -601,7 +604,7 @@ |
210 | job.bzr_branch.lock_write() |
211 | graph = job.bzr_branch.repository.get_graph() |
212 | self.addCleanup(job.bzr_branch.unlock) |
213 | - revision_ids = ['rev2a-id', 'rev3-id', 'rev2b-id', 'rev2c-id'] |
214 | + revision_ids = [b'rev2a-id', b'rev3-id', b'rev2b-id', b'rev2c-id'] |
215 | self.assertEqual(set(['foo@', 'bar@', 'baz@blaine.com', 'qux@']), |
216 | job.getAuthors(revision_ids, graph)) |
217 | |
218 | @@ -610,7 +613,7 @@ |
219 | self.useBzrBranches(direct_database=True) |
220 | branch, tree = self.makeBranchWithCommit() |
221 | job = RevisionsAddedJob.create(branch, 'rev1', 'rev1', '') |
222 | - message = job.getRevisionMessage('rev1', 1) |
223 | + message = job.getRevisionMessage(b'rev1', 1) |
224 | self.assertEqual( |
225 | '------------------------------------------------------------\n' |
226 | 'revno: 1\n' |
227 | @@ -627,9 +630,9 @@ |
228 | email='baz@blaine.com', |
229 | email_address_status=EmailAddressStatus.VALIDATED) |
230 | job = self.makeRevisionsAddedWithMergeCommit() |
231 | - message = job.getRevisionMessage('rev2d-id', 1) |
232 | + message = job.getRevisionMessage(b'rev2d-id', 1) |
233 | self.assertEqual( |
234 | - u'Merge authors:\n' |
235 | + 'Merge authors:\n' |
236 | ' bar@\n' |
237 | ' Basil Blaine (baz)\n' |
238 | ' foo@\n' |
239 | @@ -645,7 +648,7 @@ |
240 | def test_getRevisionMessage_with_merge_authors_and_authors(self): |
241 | """Merge authors are separate from normal authors.""" |
242 | job = self.makeRevisionsAddedWithMergeCommit(authors=['quxx']) |
243 | - message = job.getRevisionMessage('rev2d-id', 1) |
244 | + message = job.getRevisionMessage(b'rev2d-id', 1) |
245 | self.assertEqual( |
246 | 'Merge authors:\n' |
247 | ' bar@\n' |
248 | @@ -674,7 +677,7 @@ |
249 | """Information about related proposals is displayed.""" |
250 | job, bmp = self.makeJobAndBMP() |
251 | with dbuser('send-branch-mail'): |
252 | - message = job.getRevisionMessage('rev2d-id', 1) |
253 | + message = job.getRevisionMessage(b'rev2d-id', 1) |
254 | self.assertEqual( |
255 | 'Merge authors:\n' |
256 | ' bar@\n' |
257 | @@ -697,7 +700,7 @@ |
258 | job, bmp = self.makeJobAndBMP() |
259 | bmp2 = bmp.resubmit(bmp.registrant) |
260 | with dbuser('send-branch-mail'): |
261 | - message = job.getRevisionMessage('rev2d-id', 1) |
262 | + message = job.getRevisionMessage(b'rev2d-id', 1) |
263 | self.assertEqual( |
264 | 'Merge authors:\n' |
265 | ' bar@\n' |
266 | @@ -725,7 +728,7 @@ |
267 | reviewer = self.factory.makePerson() |
268 | bmp.nominateReviewer(reviewer, bmp.registrant) |
269 | with dbuser('send-branch-mail'): |
270 | - message = job.getRevisionMessage('rev2d-id', 1) |
271 | + message = job.getRevisionMessage(b'rev2d-id', 1) |
272 | self.assertEqual( |
273 | 'Merge authors:\n' |
274 | ' bar@\n' |
275 | @@ -755,7 +758,7 @@ |
276 | registrant=hacker) |
277 | bmp.rejectBranch(reviewer, 'rev3-id') |
278 | bmp.source_branch.last_scanned_id = 'rev3-id' |
279 | - message = job.getRevisionMessage('rev2d-id', 1) |
280 | + message = job.getRevisionMessage(b'rev2d-id', 1) |
281 | self.assertEqual( |
282 | 'Merge authors:\n' |
283 | ' bar@\n' |
284 | @@ -777,7 +780,7 @@ |
285 | """Contents of the email are as expected.""" |
286 | self.useBzrBranches(direct_database=True) |
287 | db_branch, tree = self.create_branch_and_tree() |
288 | - first_revision = 'rev-1' |
289 | + first_revision = b'rev-1' |
290 | tree.bzrdir.root_transport.put_bytes('hello.txt', 'Hello World\n') |
291 | tree.add('hello.txt') |
292 | # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is |
293 | @@ -789,7 +792,7 @@ |
294 | timestamp=1000000000.0, timezone=0) |
295 | tree.bzrdir.root_transport.put_bytes( |
296 | 'hello.txt', 'Hello World\n\nFoo Bar\n') |
297 | - second_revision = 'rev-2' |
298 | + second_revision = b'rev-2' |
299 | tree.commit( |
300 | rev_id=second_revision, message="Extended contents", |
301 | committer="Joe Bloggs <joe@example.com>", |
302 | @@ -798,30 +801,30 @@ |
303 | self.updateDBRevisions(db_branch, tree.branch, |
304 | branch_revision_history(tree.branch)) |
305 | expected = ( |
306 | - u"-" * 60 + '\n' |
307 | - "revno: 1" '\n' |
308 | - "committer: Joe Bloggs <joe@example.com>" '\n' |
309 | - "branch nick: %s" '\n' |
310 | - "timestamp: Sun 2001-09-09 01:46:40 +0000" '\n' |
311 | - "message:" '\n' |
312 | - " Log message" '\n' |
313 | - "added:" '\n' |
314 | - " hello.txt" '\n' % tree.branch.nick) |
315 | + "-" * 60 + '\n' |
316 | + "revno: 1\n" |
317 | + "committer: Joe Bloggs <joe@example.com>\n" |
318 | + "branch nick: %s\n" |
319 | + "timestamp: Sun 2001-09-09 01:46:40 +0000\n" |
320 | + "message:\n" |
321 | + " Log message\n" |
322 | + "added:\n" |
323 | + " hello.txt\n" % tree.branch.nick) |
324 | job = RevisionsAddedJob.create(db_branch, '', '', '') |
325 | switch_dbuser(config.IRevisionsAddedJobSource.dbuser) |
326 | self.assertEqual( |
327 | job.getRevisionMessage(first_revision, 1), expected) |
328 | |
329 | expected_message = ( |
330 | - u"-" * 60 + '\n' |
331 | - "revno: 2" '\n' |
332 | - "committer: Joe Bloggs <joe@example.com>" '\n' |
333 | - "branch nick: %s" '\n' |
334 | - "timestamp: Mon 2001-09-10 05:33:20 +0000" '\n' |
335 | - "message:" '\n' |
336 | - " Extended contents" '\n' |
337 | - "modified:" '\n' |
338 | - " hello.txt" '\n' % tree.branch.nick) |
339 | + "-" * 60 + '\n' |
340 | + "revno: 2\n" |
341 | + "committer: Joe Bloggs <joe@example.com>\n" |
342 | + "branch nick: %s\n" |
343 | + "timestamp: Mon 2001-09-10 05:33:20 +0000\n" |
344 | + "message:\n" |
345 | + " Extended contents\n" |
346 | + "modified:\n" |
347 | + " hello.txt\n" % tree.branch.nick) |
348 | tree.branch.lock_read() |
349 | tree.branch.unlock() |
350 | message = job.getRevisionMessage(second_revision, 2) |
351 | @@ -831,13 +834,13 @@ |
352 | """Test handling of non-ASCII commit messages.""" |
353 | self.useBzrBranches(direct_database=True) |
354 | db_branch, tree = self.create_branch_and_tree() |
355 | - rev_id = 'rev-1' |
356 | + rev_id = b'rev-1' |
357 | # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is |
358 | # required to generate the revision-id. |
359 | with override_environ(BZR_EMAIL='me@example.com'): |
360 | tree.commit( |
361 | - rev_id=rev_id, message=u"Non ASCII: \xe9", |
362 | - committer=u"Non ASCII: \xed", timestamp=1000000000.0, |
363 | + rev_id=rev_id, message="Non ASCII: \xe9", |
364 | + committer="Non ASCII: \xed", timestamp=1000000000.0, |
365 | timezone=0) |
366 | switch_dbuser('branchscanner') |
367 | self.updateDBRevisions(db_branch, tree.branch, |
368 | @@ -847,20 +850,20 @@ |
369 | message = job.getRevisionMessage(rev_id, 1) |
370 | # The revision message must be a unicode object. |
371 | expected = ( |
372 | - u'-' * 60 + '\n' |
373 | - u"revno: 1" '\n' |
374 | - u"committer: Non ASCII: \xed" '\n' |
375 | - u"branch nick: %s" '\n' |
376 | - u"timestamp: Sun 2001-09-09 01:46:40 +0000" '\n' |
377 | - u"message:" '\n' |
378 | - u" Non ASCII: \xe9" '\n' % tree.branch.nick) |
379 | + '-' * 60 + '\n' |
380 | + "revno: 1\n" |
381 | + "committer: Non ASCII: \xed\n" |
382 | + "branch nick: %s\n" |
383 | + "timestamp: Sun 2001-09-09 01:46:40 +0000\n" |
384 | + "message:\n" |
385 | + " Non ASCII: \xe9\n" % tree.branch.nick) |
386 | self.assertEqual(message, expected) |
387 | |
388 | def test_getMailerForRevision(self): |
389 | """The mailer for the revision is as expected.""" |
390 | self.useBzrBranches(direct_database=True) |
391 | branch, tree = self.makeBranchWithCommit() |
392 | - revision = tree.branch.repository.get_revision('rev1') |
393 | + revision = tree.branch.repository.get_revision(b'rev1') |
394 | job = RevisionsAddedJob.create(branch, 'rev1', 'rev1', '') |
395 | mailer = job.getMailerForRevision(revision, 1, True) |
396 | subject = mailer.generateEmail( |
397 | @@ -1016,9 +1019,9 @@ |
398 | # The method _init_translation_file_lists extracts all translation |
399 | # files from the branch but does not add changed directories to the |
400 | # template_files_changed and translation_files_changed lists . |
401 | - pot_path = u"subdir/foo.pot" |
402 | + pot_path = "subdir/foo.pot" |
403 | pot_content = self.factory.getUniqueString() |
404 | - po_path = u"subdir/foo.po" |
405 | + po_path = "subdir/foo.po" |
406 | po_content = self.factory.getUniqueString() |
407 | self._makeBranchWithTreeAndFiles(((pot_path, pot_content), |
408 | (po_path, po_content))) |
409 | |
410 | === modified file 'lib/lp/code/model/tests/test_diff.py' |
411 | --- lib/lp/code/model/tests/test_diff.py 2016-09-07 11:12:58 +0000 |
412 | +++ lib/lp/code/model/tests/test_diff.py 2017-10-04 01:52:47 +0000 |
413 | @@ -1,8 +1,10 @@ |
414 | -# Copyright 2009-2016 Canonical Ltd. This software is licensed under the |
415 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
416 | # GNU Affero General Public License version 3 (see the file LICENSE). |
417 | |
418 | """Tests for Diff, etc.""" |
419 | |
420 | +from __future__ import absolute_import, print_function, unicode_literals |
421 | + |
422 | __metaclass__ = type |
423 | |
424 | from cStringIO import StringIO |
425 | @@ -90,10 +92,10 @@ |
426 | test_case.factory.makeRevisionsForBranch(bmp.source_branch) |
427 | test_case.factory.makeRevisionsForBranch(bmp.target_branch) |
428 | bzr_target = test_case.createBzrBranch(bmp.target_branch) |
429 | - commit_file(bmp.target_branch, 'foo', 'a\n') |
430 | + commit_file(bmp.target_branch, 'foo', b'a\n') |
431 | test_case.createBzrBranch(bmp.source_branch, bzr_target) |
432 | - source_rev_id = commit_file(bmp.source_branch, 'foo', 'd\na\nb\n') |
433 | - target_rev_id = commit_file(bmp.target_branch, 'foo', 'c\na\n') |
434 | + source_rev_id = commit_file(bmp.source_branch, 'foo', b'd\na\nb\n') |
435 | + target_rev_id = commit_file(bmp.target_branch, 'foo', b'c\na\n') |
436 | return bmp, source_rev_id, target_rev_id |
437 | |
438 | |
439 | @@ -128,14 +130,14 @@ |
440 | source = bmp.source_branch |
441 | prerequisite = bmp.prerequisite_branch |
442 | target_bzr = self.createBzrBranch(target) |
443 | - commit_file(target, 'file', 'target text\n') |
444 | + commit_file(target, 'file', b'target text\n') |
445 | prerequisite_bzr = self.createBzrBranch(prerequisite, target_bzr) |
446 | commit_file( |
447 | - prerequisite, 'file', 'target text\nprerequisite text\n') |
448 | + prerequisite, 'file', b'target text\nprerequisite text\n') |
449 | source_bzr = self.createBzrBranch(source, prerequisite_bzr) |
450 | source_rev_id = commit_file( |
451 | source, 'file', |
452 | - 'target text\nprerequisite text\nsource text\n') |
453 | + b'target text\nprerequisite text\nsource text\n') |
454 | return (source_bzr, source_rev_id, target_bzr, prerequisite_bzr, |
455 | prerequisite) |
456 | |
457 | @@ -290,7 +292,7 @@ |
458 | "-b\n" |
459 | " c\n" |
460 | "+d\n" |
461 | - "+e\n") |
462 | + "+e\n").encode("UTF-8") |
463 | |
464 | diff_bytes_2 = ( |
465 | "--- bar\t2009-08-26 15:53:34.000000000 -0400\n" |
466 | @@ -312,7 +314,7 @@ |
467 | " c\n" |
468 | "+d\n" |
469 | "+e\n" |
470 | - "+f\n") |
471 | + "+f\n").encode("UTF-8") |
472 | |
473 | def test_mergePreviewWithPrerequisite(self): |
474 | # Changes introduced in the prerequisite branch are ignored. |
475 | @@ -329,8 +331,7 @@ |
476 | # affect the diff. |
477 | (source_bzr, source_rev_id, target_bzr, prerequisite_bzr, |
478 | prerequisite) = self.preparePrerequisiteMerge() |
479 | - commit_file( |
480 | - prerequisite, 'file', 'prerequisite text2\n') |
481 | + commit_file(prerequisite, 'file', b'prerequisite text2\n') |
482 | diff, conflicts = Diff.mergePreviewFromBranches( |
483 | source_bzr, source_rev_id, target_bzr, prerequisite_bzr) |
484 | transaction.commit() |
485 | @@ -348,7 +349,7 @@ |
486 | "--- foo\t2009-08-26 15:53:23.000000000 -0400\n" |
487 | "+++ foo\t2009-08-26 15:56:43.000000000 -0400\n" |
488 | "@@ -1,1 +1,1 @@\n" |
489 | - " a\r-b\r c\r+d\r+e\r+f\r") |
490 | + " a\r-b\r c\r+d\r+e\r+f\r").encode("UTF-8") |
491 | self.assertEqual({'foo': (0, 0)}, Diff.generateDiffstat(diff_bytes)) |
492 | |
493 | def test_fromFileSetsDiffstat(self): |
494 | @@ -357,7 +358,7 @@ |
495 | {'bar': (0, 3), 'baz': (2, 0), 'foo': (2, 1)}, diff.diffstat) |
496 | |
497 | def test_fromFileAcceptsBinary(self): |
498 | - diff_bytes = "Binary files a\t and b\t differ\n" |
499 | + diff_bytes = b"Binary files a\t and b\t differ\n" |
500 | diff = Diff.fromFile(StringIO(diff_bytes), len(diff_bytes)) |
501 | self.assertEqual({}, diff.diffstat) |
502 | |
503 | @@ -371,7 +372,7 @@ |
504 | def test_fromFile_withError(self): |
505 | # If the diff is formatted such that generating the diffstat fails, we |
506 | # want to record an oops but continue. |
507 | - diff_bytes = "not a real diff" |
508 | + diff_bytes = b"not a real diff" |
509 | diff = Diff.fromFile(StringIO(diff_bytes), len(diff_bytes)) |
510 | oops = self.oopses[0] |
511 | self.assertEqual('MalformedPatchHeader', oops['type']) |
512 | @@ -394,11 +395,11 @@ |
513 | if prerequisite_branch is None: |
514 | prerequisite_revision_id = None |
515 | else: |
516 | - prerequisite_revision_id = u'rev-c' |
517 | + prerequisite_revision_id = 'rev-c' |
518 | if content is None: |
519 | content = ''.join(unified_diff('', 'content')) |
520 | mp.updatePreviewDiff( |
521 | - content, u'rev-a', u'rev-b', |
522 | + content, 'rev-a', 'rev-b', |
523 | prerequisite_revision_id=prerequisite_revision_id) |
524 | # Make sure the librarian file is written. |
525 | transaction.commit() |
526 | @@ -412,11 +413,11 @@ |
527 | if merge_prerequisite is None: |
528 | prerequisite_revision_id = None |
529 | else: |
530 | - prerequisite_revision_id = u"c" * 40 |
531 | + prerequisite_revision_id = "c" * 40 |
532 | if content is None: |
533 | content = "".join(unified_diff("", "content")) |
534 | mp.updatePreviewDiff( |
535 | - content, u"a" * 40, u"b" * 40, |
536 | + content, "a" * 40, "b" * 40, |
537 | prerequisite_revision_id=prerequisite_revision_id) |
538 | # Make sure the librarian file is written. |
539 | transaction.commit() |
540 | @@ -523,10 +524,10 @@ |
541 | self.useBzrBranches(direct_database=True) |
542 | bmp = self.factory.makeBranchMergeProposal() |
543 | bzr_target = self.createBzrBranch(bmp.target_branch) |
544 | - commit_file(bmp.target_branch, 'foo', 'a\n') |
545 | + commit_file(bmp.target_branch, 'foo', b'a\n') |
546 | self.createBzrBranch(bmp.source_branch, bzr_target) |
547 | - commit_file(bmp.source_branch, 'foo', 'a\nb\n') |
548 | - commit_file(bmp.target_branch, 'foo', 'c\na\n') |
549 | + commit_file(bmp.source_branch, 'foo', b'a\nb\n') |
550 | + commit_file(bmp.target_branch, 'foo', b'c\na\n') |
551 | diff = PreviewDiff.fromBranchMergeProposal(bmp) |
552 | self.assertEqual('', diff.conflicts) |
553 | self.assertFalse(diff.has_conflicts) |
554 | @@ -657,23 +658,23 @@ |
555 | bmp = self.factory.makeBranchMergeProposal( |
556 | prerequisite_branch=prerequisite_branch) |
557 | target_branch = self.createBzrBranch(bmp.target_branch) |
558 | - old_revision_id = commit_file(bmp.target_branch, 'foo', 'a\nb\ne\n') |
559 | + old_revision_id = commit_file(bmp.target_branch, 'foo', b'a\nb\ne\n') |
560 | old_revision = self.factory.makeRevision(rev_id=old_revision_id) |
561 | source_branch = self.createBzrBranch( |
562 | bmp.source_branch, target_branch) |
563 | - commit_file(bmp.source_branch, 'foo', 'a\nc\ne\n') |
564 | + commit_file(bmp.source_branch, 'foo', b'a\nc\ne\n') |
565 | prerequisite = self.createBzrBranch( |
566 | bmp.prerequisite_branch, target_branch) |
567 | prerequisite_revision = commit_file( |
568 | - bmp.prerequisite_branch, 'foo', 'd\na\nb\ne\n') |
569 | - merge_parent = commit_file(bmp.target_branch, 'foo', 'a\nb\ne\nf\n') |
570 | + bmp.prerequisite_branch, 'foo', b'd\na\nb\ne\n') |
571 | + merge_parent = commit_file(bmp.target_branch, 'foo', b'a\nb\ne\nf\n') |
572 | source_branch.repository.fetch(target_branch.repository, |
573 | revision_id=merge_parent) |
574 | - commit_file(bmp.source_branch, 'foo', 'a\nc\ne\nf\n', [merge_parent]) |
575 | + commit_file(bmp.source_branch, 'foo', b'a\nc\ne\nf\n', [merge_parent]) |
576 | source_branch.repository.fetch(prerequisite.repository, |
577 | revision_id=prerequisite_revision) |
578 | new_revision_id = commit_file( |
579 | - bmp.source_branch, 'foo', 'd\na\nc\ne\nf\n', |
580 | + bmp.source_branch, 'foo', b'd\na\nc\ne\nf\n', |
581 | [prerequisite_revision]) |
582 | new_revision = self.factory.makeRevision(rev_id=new_revision_id) |
583 | incremental_diff = bmp.generateIncrementalDiff( |
584 | |
585 | === modified file 'lib/lp/code/model/tests/test_revision.py' |
586 | --- lib/lp/code/model/tests/test_revision.py 2015-01-29 14:14:01 +0000 |
587 | +++ lib/lp/code/model/tests/test_revision.py 2017-10-04 01:52:47 +0000 |
588 | @@ -1,8 +1,10 @@ |
589 | -# Copyright 2009-2012 Canonical Ltd. This software is licensed under the |
590 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
591 | # GNU Affero General Public License version 3 (see the file LICENSE). |
592 | |
593 | """Tests for Revisions.""" |
594 | |
595 | +from __future__ import absolute_import, print_function, unicode_literals |
596 | + |
597 | __metaclass__ = type |
598 | |
599 | from datetime import ( |
600 | @@ -228,11 +230,11 @@ |
601 | self.becomeDbUser('branchscanner') |
602 | bzr_revisions = [ |
603 | self.factory.makeBzrRevision( |
604 | - 'rev-1', |
605 | + b'rev-1', |
606 | props={ |
607 | 'prop1': 'foo', 'deb-pristine-delta': 'bar', |
608 | 'deb-pristine-delta-xz': 'baz'}), |
609 | - self.factory.makeBzrRevision('rev-2', parent_ids=['rev-1']) |
610 | + self.factory.makeBzrRevision(b'rev-2', parent_ids=[b'rev-1']) |
611 | ] |
612 | with StormStatementRecorder() as recorder: |
613 | self.revision_set.newFromBazaarRevisions(bzr_revisions) |
614 | |
615 | === modified file 'lib/lp/code/tests/test_bzr.py' |
616 | --- lib/lp/code/tests/test_bzr.py 2012-06-28 01:14:33 +0000 |
617 | +++ lib/lp/code/tests/test_bzr.py 2017-10-04 01:52:47 +0000 |
618 | @@ -1,8 +1,10 @@ |
619 | -# Copyright 2010 Canonical Ltd. This software is licensed under the |
620 | +# Copyright 2010-2017 Canonical Ltd. This software is licensed under the |
621 | # GNU Affero General Public License version 3 (see the file LICENSE). |
622 | |
623 | """Tests for lp.code.bzr.""" |
624 | |
625 | +from __future__ import absolute_import, print_function, unicode_literals |
626 | + |
627 | __metaclass__ = type |
628 | |
629 | from bzrlib.errors import NoSuchRevision |
630 | @@ -88,11 +90,11 @@ |
631 | def test_some_commits(self): |
632 | branch = self.make_branch('test') |
633 | tree = branch.bzrdir.create_workingtree() |
634 | - tree.commit('acommit', rev_id='A') |
635 | - tree.commit('bcommit', rev_id='B') |
636 | - tree.commit('ccommit', rev_id='C') |
637 | + tree.commit('acommit', rev_id=b'A') |
638 | + tree.commit('bcommit', rev_id=b'B') |
639 | + tree.commit('ccommit', rev_id=b'C') |
640 | self.assertEquals( |
641 | - ['A', 'B', 'C'], branch_revision_history(tree.branch)) |
642 | + [b'A', b'B', b'C'], branch_revision_history(tree.branch)) |
643 | |
644 | |
645 | class TestGetAncestry(TestCaseWithTransport): |
646 | @@ -102,36 +104,36 @@ |
647 | # If the revision does not exist, NoSuchRevision should be raised. |
648 | branch = self.make_branch('test') |
649 | self.assertRaises( |
650 | - NoSuchRevision, get_ancestry, branch.repository, 'orphan') |
651 | + NoSuchRevision, get_ancestry, branch.repository, b'orphan') |
652 | |
653 | def test_some(self): |
654 | # Verify ancestors are included. |
655 | branch = self.make_branch('test') |
656 | tree = branch.bzrdir.create_workingtree() |
657 | - tree.commit('msg a', rev_id='A') |
658 | - tree.commit('msg b', rev_id='B') |
659 | - tree.commit('msg c', rev_id='C') |
660 | - self.assertEqual( |
661 | - set(['A']), get_ancestry(branch.repository, 'A')) |
662 | - self.assertEqual( |
663 | - set(['A', 'B']), get_ancestry(branch.repository, 'B')) |
664 | - self.assertEqual( |
665 | - set(['A', 'B', 'C']), get_ancestry(branch.repository, 'C')) |
666 | + tree.commit('msg a', rev_id=b'A') |
667 | + tree.commit('msg b', rev_id=b'B') |
668 | + tree.commit('msg c', rev_id=b'C') |
669 | + self.assertEqual( |
670 | + set([b'A']), get_ancestry(branch.repository, b'A')) |
671 | + self.assertEqual( |
672 | + set([b'A', b'B']), get_ancestry(branch.repository, b'B')) |
673 | + self.assertEqual( |
674 | + set([b'A', b'B', b'C']), get_ancestry(branch.repository, b'C')) |
675 | |
676 | def test_children(self): |
677 | # Verify non-mainline children are included. |
678 | branch = self.make_branch('test') |
679 | tree = branch.bzrdir.create_workingtree() |
680 | - tree.commit('msg a', rev_id='A') |
681 | + tree.commit('msg a', rev_id=b'A') |
682 | branch.generate_revision_history(NULL_REVISION) |
683 | tree.set_parent_ids([]) |
684 | - tree.commit('msg b', rev_id='B') |
685 | - branch.generate_revision_history('A') |
686 | - tree.set_parent_ids(['A', 'B']) |
687 | - tree.commit('msg c', rev_id='C') |
688 | - self.assertEqual( |
689 | - set(['A']), get_ancestry(branch.repository, 'A')) |
690 | - self.assertEqual( |
691 | - set(['B']), get_ancestry(branch.repository, 'B')) |
692 | - self.assertEqual( |
693 | - set(['A', 'B', 'C']), get_ancestry(branch.repository, 'C')) |
694 | + tree.commit('msg b', rev_id=b'B') |
695 | + branch.generate_revision_history(b'A') |
696 | + tree.set_parent_ids([b'A', b'B']) |
697 | + tree.commit('msg c', rev_id=b'C') |
698 | + self.assertEqual( |
699 | + set([b'A']), get_ancestry(branch.repository, b'A')) |
700 | + self.assertEqual( |
701 | + set([b'B']), get_ancestry(branch.repository, b'B')) |
702 | + self.assertEqual( |
703 | + set([b'A', b'B', b'C']), get_ancestry(branch.repository, b'C')) |
704 | |
705 | === modified file 'lib/lp/code/tests/test_directbranchcommit.py' |
706 | --- lib/lp/code/tests/test_directbranchcommit.py 2012-03-27 14:11:03 +0000 |
707 | +++ lib/lp/code/tests/test_directbranchcommit.py 2017-10-04 01:52:47 +0000 |
708 | @@ -1,8 +1,10 @@ |
709 | -# Copyright 2009-2012 Canonical Ltd. This software is licensed under the |
710 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
711 | # GNU Affero General Public License version 3 (see the file LICENSE). |
712 | |
713 | """Tests for `DirectBranchCommit`.""" |
714 | |
715 | +from __future__ import absolute_import, print_function, unicode_literals |
716 | + |
717 | __metaclass__ = type |
718 | |
719 | from testtools.testcase import ExpectedException |
720 | @@ -73,10 +75,10 @@ |
721 | |
722 | def test_DirectBranchCommit_empty_initial_commit_noop(self): |
723 | # An empty initial commit to a branch is a no-op. |
724 | - self.assertEqual('null:', self.tree.branch.last_revision()) |
725 | + self.assertEqual(b'null:', self.tree.branch.last_revision()) |
726 | self.committer.commit('') |
727 | self.assertEqual({}, self._getContents()) |
728 | - self.assertEqual('null:', self.tree.branch.last_revision()) |
729 | + self.assertEqual(b'null:', self.tree.branch.last_revision()) |
730 | |
731 | def _addInitialCommit(self): |
732 | self.committer._getDir('') |
733 | @@ -86,7 +88,7 @@ |
734 | |
735 | def test_DirectBranchCommit_commits_no_changes(self): |
736 | # Committing nothing to an empty branch leaves its tree empty. |
737 | - self.assertEqual('null:', self.tree.branch.last_revision()) |
738 | + self.assertEqual(b'null:', self.tree.branch.last_revision()) |
739 | old_rev_id = self.tree.branch.last_revision() |
740 | self._addInitialCommit() |
741 | self.committer.commit('') |
742 | @@ -96,17 +98,17 @@ |
743 | def test_DirectBranchCommit_rejects_change_after_commit(self): |
744 | # Changes are not accepted after commit. |
745 | self.committer.commit('') |
746 | - self.assertRaises(AssertionError, self.committer.writeFile, 'x', 'y') |
747 | + self.assertRaises(AssertionError, self.committer.writeFile, 'x', b'y') |
748 | |
749 | def test_DirectBranchCommit_adds_file(self): |
750 | # DirectBranchCommit can add a new file to the branch. |
751 | - self.committer.writeFile('file.txt', 'contents') |
752 | + self.committer.writeFile('file.txt', b'contents') |
753 | self.committer.commit('') |
754 | - self.assertEqual({'file.txt': 'contents'}, self._getContents()) |
755 | + self.assertEqual({'file.txt': b'contents'}, self._getContents()) |
756 | |
757 | def test_commit_returns_revision_id(self): |
758 | # DirectBranchCommit.commit returns the new revision_id. |
759 | - self.committer.writeFile('file.txt', 'contents') |
760 | + self.committer.writeFile('file.txt', b'contents') |
761 | revision_id = self.committer.commit('') |
762 | branch_revision_id = self.committer.bzrbranch.last_revision() |
763 | self.assertEqual(branch_revision_id, revision_id) |
764 | @@ -116,56 +118,56 @@ |
765 | self._tearDownCommitter() |
766 | # Merge parents cannot be specified for initial commit, so do an |
767 | # empty commit. |
768 | - self.tree.commit('foo', committer='foo@bar', rev_id='foo') |
769 | + self.tree.commit('foo', committer='foo@bar', rev_id=b'foo') |
770 | self.db_branch.last_mirrored_id = 'foo' |
771 | committer = DirectBranchCommit( |
772 | - self.db_branch, merge_parents=['parent-1', 'parent-2']) |
773 | + self.db_branch, merge_parents=[b'parent-1', b'parent-2']) |
774 | committer.last_scanned_id = ( |
775 | committer.bzrbranch.last_revision()) |
776 | - committer.writeFile('file.txt', 'contents') |
777 | + committer.writeFile('file.txt', b'contents') |
778 | committer.commit('') |
779 | branch_revision_id = committer.bzrbranch.last_revision() |
780 | branch_revision = committer.bzrbranch.repository.get_revision( |
781 | branch_revision_id) |
782 | self.assertEqual( |
783 | - ['parent-1', 'parent-2'], branch_revision.parent_ids[1:]) |
784 | + [b'parent-1', b'parent-2'], branch_revision.parent_ids[1:]) |
785 | |
786 | def test_DirectBranchCommit_aborts_cleanly(self): |
787 | # If a DirectBranchCommit is not committed, its changes do not |
788 | # go into the branch. |
789 | - self.committer.writeFile('oldfile.txt', 'already here') |
790 | + self.committer.writeFile('oldfile.txt', b'already here') |
791 | self.committer.commit('') |
792 | self._setUpCommitter() |
793 | - self.committer.writeFile('newfile.txt', 'adding this') |
794 | + self.committer.writeFile('newfile.txt', b'adding this') |
795 | self._setUpCommitter() |
796 | - self.assertEqual({'oldfile.txt': 'already here'}, self._getContents()) |
797 | + self.assertEqual({'oldfile.txt': b'already here'}, self._getContents()) |
798 | self.committer.unlock() |
799 | |
800 | def test_DirectBranchCommit_updates_file(self): |
801 | # DirectBranchCommit can replace a file in the branch. |
802 | - self.committer.writeFile('file.txt', 'contents') |
803 | + self.committer.writeFile('file.txt', b'contents') |
804 | self.committer.commit('') |
805 | self._setUpCommitter() |
806 | - self.committer.writeFile('file.txt', 'changed') |
807 | + self.committer.writeFile('file.txt', b'changed') |
808 | self.committer.commit('') |
809 | - self.assertEqual({'file.txt': 'changed'}, self._getContents()) |
810 | + self.assertEqual({'file.txt': b'changed'}, self._getContents()) |
811 | |
812 | def test_DirectBranchCommit_creates_directories(self): |
813 | # Files can be in subdirectories. |
814 | - self.committer.writeFile('a/b/c.txt', 'ctext') |
815 | + self.committer.writeFile('a/b/c.txt', b'ctext') |
816 | self.committer.commit('') |
817 | - self.assertEqual({'a/b/c.txt': 'ctext'}, self._getContents()) |
818 | + self.assertEqual({'a/b/c.txt': b'ctext'}, self._getContents()) |
819 | |
820 | def test_DirectBranchCommit_adds_directories(self): |
821 | # Creating a subdirectory of an existing directory also works. |
822 | - self.committer.writeFile('a/n.txt', 'aa') |
823 | + self.committer.writeFile('a/n.txt', b'aa') |
824 | self.committer.commit('') |
825 | self._setUpCommitter() |
826 | - self.committer.writeFile('a/b/m.txt', 'aa/bb') |
827 | + self.committer.writeFile('a/b/m.txt', b'aa/bb') |
828 | self.committer.commit('') |
829 | expected = { |
830 | - 'a/n.txt': 'aa', |
831 | - 'a/b/m.txt': 'aa/bb', |
832 | + 'a/n.txt': b'aa', |
833 | + 'a/b/m.txt': b'aa/bb', |
834 | } |
835 | self.assertEqual(expected, self._getContents()) |
836 | |
837 | @@ -173,47 +175,47 @@ |
838 | # If a directory doesn't exist in the committed branch, creating |
839 | # it twice would be an error. DirectBranchCommit doesn't do |
840 | # that. |
841 | - self.committer.writeFile('foo/x.txt', 'x') |
842 | - self.committer.writeFile('foo/y.txt', 'y') |
843 | + self.committer.writeFile('foo/x.txt', b'x') |
844 | + self.committer.writeFile('foo/y.txt', b'y') |
845 | self.committer.commit('') |
846 | expected = { |
847 | - 'foo/x.txt': 'x', |
848 | - 'foo/y.txt': 'y', |
849 | + 'foo/x.txt': b'x', |
850 | + 'foo/y.txt': b'y', |
851 | } |
852 | self.assertEqual(expected, self._getContents()) |
853 | |
854 | def test_DirectBranchCommit_writes_new_file_twice(self): |
855 | # If you write the same new file multiple times before |
856 | # committing, the original wins. |
857 | - self.committer.writeFile('x.txt', 'aaa') |
858 | - self.committer.writeFile('x.txt', 'bbb') |
859 | + self.committer.writeFile('x.txt', b'aaa') |
860 | + self.committer.writeFile('x.txt', b'bbb') |
861 | self.committer.commit('') |
862 | - self.assertEqual({'x.txt': 'aaa'}, self._getContents()) |
863 | + self.assertEqual({'x.txt': b'aaa'}, self._getContents()) |
864 | |
865 | def test_DirectBranchCommit_updates_file_twice(self): |
866 | # If you update the same file multiple times before committing, |
867 | # the original wins. |
868 | - self.committer.writeFile('y.txt', 'aaa') |
869 | + self.committer.writeFile('y.txt', b'aaa') |
870 | self.committer.commit('') |
871 | self._setUpCommitter() |
872 | - self.committer.writeFile('y.txt', 'bbb') |
873 | - self.committer.writeFile('y.txt', 'ccc') |
874 | + self.committer.writeFile('y.txt', b'bbb') |
875 | + self.committer.writeFile('y.txt', b'ccc') |
876 | self.committer.commit('') |
877 | - self.assertEqual({'y.txt': 'bbb'}, self._getContents()) |
878 | + self.assertEqual({'y.txt': b'bbb'}, self._getContents()) |
879 | |
880 | def test_DirectBranchCommit_detects_race_condition(self): |
881 | # If the branch has been updated since it was last scanned, |
882 | # attempting to commit to it will raise ConcurrentUpdateError. |
883 | - self.committer.writeFile('hi.c', 'main(){puts("hi world");}') |
884 | + self.committer.writeFile('hi.c', b'main(){puts("hi world");}') |
885 | self.committer.commit('') |
886 | self._setUpCommitter(False) |
887 | - self.committer.writeFile('hi.py', 'print "hi world"') |
888 | + self.committer.writeFile('hi.py', b'print "hi world"') |
889 | self.assertRaises(ConcurrentUpdateError, self.committer.commit, '') |
890 | |
891 | def test_DirectBranchCommit_records_committed_revision_id(self): |
892 | # commit() records the committed revision in the database record for |
893 | # the branch. |
894 | - self.committer.writeFile('hi.c', 'main(){puts("hi world");}') |
895 | + self.committer.writeFile('hi.c', b'main(){puts("hi world");}') |
896 | revid = self.committer.commit('') |
897 | self.assertEqual(revid, self.db_branch.last_mirrored_id) |
898 | |
899 | @@ -225,7 +227,7 @@ |
900 | fake_commit = FakeMethod() |
901 | self.committer.transform_preview.commit = fake_commit |
902 | |
903 | - self.committer.writeFile('x', 'y') |
904 | + self.committer.writeFile('x', b'y') |
905 | self.committer.commit('') |
906 | |
907 | commit_args, commit_kwargs = fake_commit.calls[-1] |