Merge ~cjwatson/launchpad:pyupgrade-py3-code into launchpad:master
- Git
- lp:~cjwatson/launchpad
- pyupgrade-py3-code
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 303156e5913eecfffd1c7307ba219ec3f6442b90 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:pyupgrade-py3-code |
Merge into: | launchpad:master |
Diff against target: |
3920 lines (+422/-478) 87 files modified
.git-blame-ignore-revs (+2/-0) .pre-commit-config.yaml (+1/-1) lib/lp/code/adapters/tests/test_gitrepository.py (+7/-7) lib/lp/code/errors.py (+10/-14) lib/lp/code/event/git.py (+1/-1) lib/lp/code/feed/branch.py (+3/-3) lib/lp/code/interfaces/branch.py (+5/-5) lib/lp/code/interfaces/branchjob.py (+4/-4) lib/lp/code/interfaces/codeimport.py (+1/-1) lib/lp/code/interfaces/gitrepository.py (+1/-1) lib/lp/code/interfaces/sourcepackagerecipe.py (+2/-2) lib/lp/code/mail/branch.py (+3/-4) lib/lp/code/mail/sourcepackagerecipebuild.py (+2/-5) lib/lp/code/mail/tests/test_branch.py (+1/-1) lib/lp/code/mail/tests/test_branchmergeproposal.py (+1/-1) lib/lp/code/mail/tests/test_codehandler.py (+7/-9) lib/lp/code/mail/tests/test_codeimport.py (+1/-1) lib/lp/code/mail/tests/test_sourcepackagerecipebuild.py (+9/-9) lib/lp/code/model/branch.py (+2/-2) lib/lp/code/model/branchcollection.py (+2/-2) lib/lp/code/model/branchhosting.py (+1/-4) lib/lp/code/model/branchjob.py (+5/-5) lib/lp/code/model/branchmergeproposal.py (+6/-11) lib/lp/code/model/branchmergeproposaljob.py (+1/-1) lib/lp/code/model/branchsubscription.py (+1/-1) lib/lp/code/model/branchtarget.py (+1/-1) lib/lp/code/model/codeimport.py (+1/-1) lib/lp/code/model/codeimportevent.py (+10/-12) lib/lp/code/model/codeimportjob.py (+2/-2) lib/lp/code/model/codeimportmachine.py (+2/-2) lib/lp/code/model/codeimportresult.py (+2/-2) lib/lp/code/model/codereviewinlinecomment.py (+1/-2) lib/lp/code/model/diff.py (+8/-8) lib/lp/code/model/gitactivity.py (+1/-1) lib/lp/code/model/gitcollection.py (+1/-1) lib/lp/code/model/githosting.py (+16/-31) lib/lp/code/model/gitjob.py (+2/-2) lib/lp/code/model/gitlookup.py (+3/-5) lib/lp/code/model/gitref.py (+5/-5) lib/lp/code/model/gitrepository.py (+9/-11) lib/lp/code/model/gitrule.py (+1/-1) lib/lp/code/model/gitsubscription.py (+1/-1) lib/lp/code/model/recipebuilder.py (+1/-2) lib/lp/code/model/revision.py (+2/-2) lib/lp/code/model/sourcepackagerecipebuild.py (+1/-1) lib/lp/code/model/sourcepackagerecipedata.py (+3/-3) lib/lp/code/model/tests/test_branch.py (+6/-6) lib/lp/code/model/tests/test_branchcollection.py (+1/-1) lib/lp/code/model/tests/test_branchhosting.py (+6/-7) lib/lp/code/model/tests/test_branchjob.py (+1/-1) lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py (+2/-4) lib/lp/code/model/tests/test_branchmergeproposal.py (+7/-8) lib/lp/code/model/tests/test_branchmergeproposaljobs.py (+1/-2) lib/lp/code/model/tests/test_branchnamespace.py (+2/-3) lib/lp/code/model/tests/test_codeimport.py (+7/-8) lib/lp/code/model/tests/test_codeimportjob.py (+13/-13) lib/lp/code/model/tests/test_codeimportmachine.py (+1/-2) lib/lp/code/model/tests/test_codereviewkarma.py (+1/-1) lib/lp/code/model/tests/test_gitcollection.py (+1/-1) lib/lp/code/model/tests/test_githosting.py (+7/-8) lib/lp/code/model/tests/test_gitlookup.py (+5/-5) lib/lp/code/model/tests/test_gitnamespace.py (+3/-5) lib/lp/code/model/tests/test_gitref.py (+2/-2) lib/lp/code/model/tests/test_gitrepository.py (+13/-14) lib/lp/code/model/tests/test_revision.py (+1/-1) lib/lp/code/model/tests/test_revisionauthor.py (+9/-9) lib/lp/code/model/tests/test_sourcepackagerecipe.py (+1/-1) lib/lp/code/scripts/repackgitrepository.py (+2/-3) lib/lp/code/scripts/tests/test_repack_git_repositories.py (+2/-2) lib/lp/code/scripts/tests/test_request_daily_builds.py (+3/-3) lib/lp/code/tests/helpers.py (+1/-2) lib/lp/code/tests/test_branch.py (+1/-1) lib/lp/code/tests/test_branch_webservice.py (+1/-1) lib/lp/code/tests/test_bzr.py (+4/-5) lib/lp/code/tests/test_directbranchcommit.py (+2/-2) lib/lp/code/tests/test_project.py (+1/-1) lib/lp/code/vocabularies/branch.py (+2/-2) lib/lp/code/vocabularies/gitref.py (+2/-2) lib/lp/code/vocabularies/gitrepository.py (+1/-2) lib/lp/code/vocabularies/gitrule.py (+1/-1) lib/lp/code/vocabularies/tests/test_branch_vocabularies.py (+4/-5) lib/lp/code/vocabularies/tests/test_gitrepository_vocabularies.py (+11/-11) lib/lp/code/xmlrpc/codehosting.py (+1/-1) lib/lp/code/xmlrpc/git.py (+5/-5) lib/lp/code/xmlrpc/tests/test_branch.py (+3/-3) lib/lp/code/xmlrpc/tests/test_codehosting.py (+44/-44) lib/lp/code/xmlrpc/tests/test_git.py (+89/-89) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Colin Watson (community) | Approve | ||
Review via email:
|
Commit message
lp.code: Apply "pyupgrade --py3-plus"
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs | |||
2 | index 91cb020..4691daf 100644 | |||
3 | --- a/.git-blame-ignore-revs | |||
4 | +++ b/.git-blame-ignore-revs | |||
5 | @@ -22,3 +22,5 @@ b6725842a2470e3927bb73bf400c4476a06ee3ba | |||
6 | 22 | 474f07ab7c3f28d8b6b8e4f1bd4c56832cec3fab | 22 | 474f07ab7c3f28d8b6b8e4f1bd4c56832cec3fab |
7 | 23 | # apply pyupgrade --py3-plus to lp.code.browser | 23 | # apply pyupgrade --py3-plus to lp.code.browser |
8 | 24 | 47ee1259461aa54ad7ee967e85f6131be2b74125 | 24 | 47ee1259461aa54ad7ee967e85f6131be2b74125 |
9 | 25 | # apply pyupgrade --py3-plus to lp.code | ||
10 | 26 | cee9b128d3e49ca814464eeeeec50e6bcabcc4ba | ||
11 | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml | |||
12 | index 47ab095..d82d7fe 100644 | |||
13 | --- a/.pre-commit-config.yaml | |||
14 | +++ b/.pre-commit-config.yaml | |||
15 | @@ -48,7 +48,7 @@ repos: | |||
16 | 48 | |bugs | 48 | |bugs |
17 | 49 | |buildmaster | 49 | |buildmaster |
18 | 50 | |charms | 50 | |charms |
20 | 51 | |code/browser | 51 | |code |
21 | 52 | )/ | 52 | )/ |
22 | 53 | - repo: https://github.com/PyCQA/isort | 53 | - repo: https://github.com/PyCQA/isort |
23 | 54 | rev: 5.9.2 | 54 | rev: 5.9.2 |
24 | diff --git a/lib/lp/code/adapters/tests/test_gitrepository.py b/lib/lp/code/adapters/tests/test_gitrepository.py | |||
25 | index 5363a15..9983274 100644 | |||
26 | --- a/lib/lp/code/adapters/tests/test_gitrepository.py | |||
27 | +++ b/lib/lp/code/adapters/tests/test_gitrepository.py | |||
28 | @@ -19,7 +19,7 @@ class TestGitRepositoryDelta(TestCaseWithFactory): | |||
29 | 19 | 19 | ||
30 | 20 | def test_no_modification(self): | 20 | def test_no_modification(self): |
31 | 21 | # If there are no modifications, no delta is returned. | 21 | # If there are no modifications, no delta is returned. |
33 | 22 | repository = self.factory.makeGitRepository(name=u"foo") | 22 | repository = self.factory.makeGitRepository(name="foo") |
34 | 23 | old_repository = Snapshot(repository, providing=providedBy(repository)) | 23 | old_repository = Snapshot(repository, providing=providedBy(repository)) |
35 | 24 | delta = GitRepositoryDelta.construct( | 24 | delta = GitRepositoryDelta.construct( |
36 | 25 | old_repository, repository, repository.owner) | 25 | old_repository, repository, repository.owner) |
37 | @@ -30,18 +30,18 @@ class TestGitRepositoryDelta(TestCaseWithFactory): | |||
38 | 30 | owner = self.factory.makePerson(name="person") | 30 | owner = self.factory.makePerson(name="person") |
39 | 31 | project = self.factory.makeProduct(name="project") | 31 | project = self.factory.makeProduct(name="project") |
40 | 32 | repository = self.factory.makeGitRepository( | 32 | repository = self.factory.makeGitRepository( |
42 | 33 | owner=owner, target=project, name=u"foo") | 33 | owner=owner, target=project, name="foo") |
43 | 34 | old_repository = Snapshot(repository, providing=providedBy(repository)) | 34 | old_repository = Snapshot(repository, providing=providedBy(repository)) |
44 | 35 | with person_logged_in(repository.owner): | 35 | with person_logged_in(repository.owner): |
46 | 36 | repository.setName(u"bar", repository.owner) | 36 | repository.setName("bar", repository.owner) |
47 | 37 | delta = GitRepositoryDelta.construct(old_repository, repository, owner) | 37 | delta = GitRepositoryDelta.construct(old_repository, repository, owner) |
48 | 38 | self.assertIsNotNone(delta) | 38 | self.assertIsNotNone(delta) |
49 | 39 | self.assertThat(delta, MatchesStructure.byEquality( | 39 | self.assertThat(delta, MatchesStructure.byEquality( |
50 | 40 | name={ | 40 | name={ |
53 | 41 | "old": u"foo", | 41 | "old": "foo", |
54 | 42 | "new": u"bar", | 42 | "new": "bar", |
55 | 43 | }, | 43 | }, |
56 | 44 | git_identity={ | 44 | git_identity={ |
59 | 45 | "old": u"lp:~person/project/+git/foo", | 45 | "old": "lp:~person/project/+git/foo", |
60 | 46 | "new": u"lp:~person/project/+git/bar", | 46 | "new": "lp:~person/project/+git/bar", |
61 | 47 | })) | 47 | })) |
62 | diff --git a/lib/lp/code/errors.py b/lib/lp/code/errors.py | |||
63 | index 885662e..a4dc375 100644 | |||
64 | --- a/lib/lp/code/errors.py | |||
65 | +++ b/lib/lp/code/errors.py | |||
66 | @@ -70,7 +70,6 @@ import http.client | |||
67 | 70 | 70 | ||
68 | 71 | from breezy.plugins.builder.recipe import RecipeParseError | 71 | from breezy.plugins.builder.recipe import RecipeParseError |
69 | 72 | from lazr.restful.declarations import error_status | 72 | from lazr.restful.declarations import error_status |
70 | 73 | import six | ||
71 | 74 | 73 | ||
72 | 75 | from lp.app.errors import ( | 74 | from lp.app.errors import ( |
73 | 76 | NameLookupFailed, | 75 | NameLookupFailed, |
74 | @@ -203,8 +202,7 @@ class CannotUpgradeBranch(Exception): | |||
75 | 203 | """"Made for subclassing.""" | 202 | """"Made for subclassing.""" |
76 | 204 | 203 | ||
77 | 205 | def __init__(self, branch): | 204 | def __init__(self, branch): |
80 | 206 | super(CannotUpgradeBranch, self).__init__( | 205 | super().__init__(self._msg_template % branch.bzr_identity) |
79 | 207 | self._msg_template % branch.bzr_identity) | ||
81 | 208 | self.branch = branch | 206 | self.branch = branch |
82 | 209 | 207 | ||
83 | 210 | 208 | ||
84 | @@ -254,7 +252,7 @@ class BranchMergeProposalExists(InvalidBranchMergeProposal): | |||
85 | 254 | display_name = "displayname" | 252 | display_name = "displayname" |
86 | 255 | else: | 253 | else: |
87 | 256 | display_name = "display_name" | 254 | display_name = "display_name" |
89 | 257 | super(BranchMergeProposalExists, self).__init__( | 255 | super().__init__( |
90 | 258 | 'There is already a branch merge proposal registered for ' | 256 | 'There is already a branch merge proposal registered for ' |
91 | 259 | 'branch %s to land on %s that is still active.' % | 257 | 'branch %s to land on %s that is still active.' % |
92 | 260 | (getattr(existing_proposal.merge_source, display_name), | 258 | (getattr(existing_proposal.merge_source, display_name), |
93 | @@ -363,7 +361,7 @@ class BranchFileNotFound(BranchHostingFault): | |||
94 | 363 | """Raised when a file does not exist in a branch.""" | 361 | """Raised when a file does not exist in a branch.""" |
95 | 364 | 362 | ||
96 | 365 | def __init__(self, branch_id, filename=None, file_id=None, rev=None): | 363 | def __init__(self, branch_id, filename=None, file_id=None, rev=None): |
98 | 366 | super(BranchFileNotFound, self).__init__() | 364 | super().__init__() |
99 | 367 | if (filename is None) == (file_id is None): | 365 | if (filename is None) == (file_id is None): |
100 | 368 | raise AssertionError( | 366 | raise AssertionError( |
101 | 369 | "Exactly one of filename and file_id must be given.") | 367 | "Exactly one of filename and file_id must be given.") |
102 | @@ -416,7 +414,6 @@ class GitRepositoryCreationForbidden(GitRepositoryCreationException): | |||
103 | 416 | """ | 414 | """ |
104 | 417 | 415 | ||
105 | 418 | 416 | ||
106 | 419 | @six.python_2_unicode_compatible | ||
107 | 420 | @error_status(http.client.BAD_REQUEST) | 417 | @error_status(http.client.BAD_REQUEST) |
108 | 421 | class GitRepositoryCreatorNotMemberOfOwnerTeam(GitRepositoryCreationException): | 418 | class GitRepositoryCreatorNotMemberOfOwnerTeam(GitRepositoryCreationException): |
109 | 422 | """Git repository creator is not a member of the owner team. | 419 | """Git repository creator is not a member of the owner team. |
110 | @@ -435,7 +432,6 @@ class GitRepositoryCreatorNotMemberOfOwnerTeam(GitRepositoryCreationException): | |||
111 | 435 | return message | 432 | return message |
112 | 436 | 433 | ||
113 | 437 | 434 | ||
114 | 438 | @six.python_2_unicode_compatible | ||
115 | 439 | @error_status(http.client.BAD_REQUEST) | 435 | @error_status(http.client.BAD_REQUEST) |
116 | 440 | class GitRepositoryCreatorNotOwner(GitRepositoryCreationException): | 436 | class GitRepositoryCreatorNotOwner(GitRepositoryCreationException): |
117 | 441 | """A user cannot create a Git repository belonging to another user. | 437 | """A user cannot create a Git repository belonging to another user. |
118 | @@ -458,7 +454,7 @@ class GitRepositoryCreationFault(Exception): | |||
119 | 458 | """Raised when there is a hosting fault creating a Git repository.""" | 454 | """Raised when there is a hosting fault creating a Git repository.""" |
120 | 459 | 455 | ||
121 | 460 | def __init__(self, message, path): | 456 | def __init__(self, message, path): |
123 | 461 | super(GitRepositoryCreationFault, self).__init__(message) | 457 | super().__init__(message) |
124 | 462 | self.path = path | 458 | self.path = path |
125 | 463 | 459 | ||
126 | 464 | 460 | ||
127 | @@ -470,7 +466,7 @@ class GitRepositoryBlobNotFound(GitRepositoryScanFault): | |||
128 | 470 | """Raised when a blob does not exist in a repository.""" | 466 | """Raised when a blob does not exist in a repository.""" |
129 | 471 | 467 | ||
130 | 472 | def __init__(self, path, filename, rev=None): | 468 | def __init__(self, path, filename, rev=None): |
132 | 473 | super(GitRepositoryBlobNotFound, self).__init__() | 469 | super().__init__() |
133 | 474 | self.path = path | 470 | self.path = path |
134 | 475 | self.filename = filename | 471 | self.filename = filename |
135 | 476 | self.rev = rev | 472 | self.rev = rev |
136 | @@ -486,7 +482,7 @@ class GitRepositoryBlobUnsupportedRemote(Exception): | |||
137 | 486 | """Raised when trying to fetch a blob from an unsupported remote host.""" | 482 | """Raised when trying to fetch a blob from an unsupported remote host.""" |
138 | 487 | 483 | ||
139 | 488 | def __init__(self, repository_url): | 484 | def __init__(self, repository_url): |
141 | 489 | super(GitRepositoryBlobUnsupportedRemote, self).__init__() | 485 | super().__init__() |
142 | 490 | self.repository_url = repository_url | 486 | self.repository_url = repository_url |
143 | 491 | 487 | ||
144 | 492 | def __str__(self): | 488 | def __str__(self): |
145 | @@ -565,7 +561,7 @@ class CannotModifyNonHostedGitRepository(Exception): | |||
146 | 565 | """Raised when trying to modify a non-hosted Git repository.""" | 561 | """Raised when trying to modify a non-hosted Git repository.""" |
147 | 566 | 562 | ||
148 | 567 | def __init__(self, repository): | 563 | def __init__(self, repository): |
150 | 568 | super(CannotModifyNonHostedGitRepository, self).__init__( | 564 | super().__init__( |
151 | 569 | "Cannot modify non-hosted Git repository %s." % | 565 | "Cannot modify non-hosted Git repository %s." % |
152 | 570 | repository.display_name) | 566 | repository.display_name) |
153 | 571 | 567 | ||
154 | @@ -579,7 +575,7 @@ class CodeImportAlreadyRequested(Exception): | |||
155 | 579 | """Raised when the user requests an import that is already requested.""" | 575 | """Raised when the user requests an import that is already requested.""" |
156 | 580 | 576 | ||
157 | 581 | def __init__(self, msg, requesting_user): | 577 | def __init__(self, msg, requesting_user): |
159 | 582 | super(CodeImportAlreadyRequested, self).__init__(msg) | 578 | super().__init__(msg) |
160 | 583 | self.requesting_user = requesting_user | 579 | self.requesting_user = requesting_user |
161 | 584 | 580 | ||
162 | 585 | 581 | ||
163 | @@ -593,7 +589,7 @@ class CodeImportInvalidTargetType(Exception): | |||
164 | 593 | """Raised for code imports with an invalid target for their type.""" | 589 | """Raised for code imports with an invalid target for their type.""" |
165 | 594 | 590 | ||
166 | 595 | def __init__(self, target, target_rcs_type): | 591 | def __init__(self, target, target_rcs_type): |
168 | 596 | super(CodeImportInvalidTargetType, self).__init__( | 592 | super().__init__( |
169 | 597 | "Objects of type %s do not support code imports targeting %s." % | 593 | "Objects of type %s do not support code imports targeting %s." % |
170 | 598 | (target.__class__.__name__, target_rcs_type)) | 594 | (target.__class__.__name__, target_rcs_type)) |
171 | 599 | 595 | ||
172 | @@ -603,7 +599,7 @@ class TooNewRecipeFormat(Exception): | |||
173 | 603 | """The format of the recipe supplied was too new.""" | 599 | """The format of the recipe supplied was too new.""" |
174 | 604 | 600 | ||
175 | 605 | def __init__(self, supplied_format, newest_supported): | 601 | def __init__(self, supplied_format, newest_supported): |
177 | 606 | super(TooNewRecipeFormat, self).__init__() | 602 | super().__init__() |
178 | 607 | self.supplied_format = supplied_format | 603 | self.supplied_format = supplied_format |
179 | 608 | self.newest_supported = newest_supported | 604 | self.newest_supported = newest_supported |
180 | 609 | 605 | ||
181 | diff --git a/lib/lp/code/event/git.py b/lib/lp/code/event/git.py | |||
182 | index bc89694..317c687 100644 | |||
183 | --- a/lib/lp/code/event/git.py | |||
184 | +++ b/lib/lp/code/event/git.py | |||
185 | @@ -18,6 +18,6 @@ class GitRefsUpdatedEvent(ObjectEvent): | |||
186 | 18 | """See `IGitRefsUpdatedEvent`.""" | 18 | """See `IGitRefsUpdatedEvent`.""" |
187 | 19 | 19 | ||
188 | 20 | def __init__(self, repository, paths, logger): | 20 | def __init__(self, repository, paths, logger): |
190 | 21 | super(GitRefsUpdatedEvent, self).__init__(repository) | 21 | super().__init__(repository) |
191 | 22 | self.paths = paths | 22 | self.paths = paths |
192 | 23 | self.logger = logger | 23 | self.logger = logger |
193 | diff --git a/lib/lp/code/feed/branch.py b/lib/lp/code/feed/branch.py | |||
194 | index 3339134..27d2047 100644 | |||
195 | --- a/lib/lp/code/feed/branch.py | |||
196 | +++ b/lib/lp/code/feed/branch.py | |||
197 | @@ -67,7 +67,7 @@ class BranchFeedContentView(BranchView): | |||
198 | 67 | 67 | ||
199 | 68 | def __init__(self, context, request, feed, | 68 | def __init__(self, context, request, feed, |
200 | 69 | template='templates/branch.pt'): | 69 | template='templates/branch.pt'): |
202 | 70 | super(BranchFeedContentView, self).__init__(context, request) | 70 | super().__init__(context, request) |
203 | 71 | self.feed = feed | 71 | self.feed = feed |
204 | 72 | self.template_ = template | 72 | self.template_ = template |
205 | 73 | 73 | ||
206 | @@ -196,7 +196,7 @@ class RevisionFeedContentView(LaunchpadView): | |||
207 | 196 | """View for a revision feed contents.""" | 196 | """View for a revision feed contents.""" |
208 | 197 | 197 | ||
209 | 198 | def __init__(self, context, request, feed): | 198 | def __init__(self, context, request, feed): |
211 | 199 | super(RevisionFeedContentView, self).__init__(context, request) | 199 | super().__init__(context, request) |
212 | 200 | self.feed = feed | 200 | self.feed = feed |
213 | 201 | 201 | ||
214 | 202 | @cachedproperty | 202 | @cachedproperty |
215 | @@ -391,7 +391,7 @@ class BranchFeed(BranchFeedBase): | |||
216 | 391 | def initialize(self): | 391 | def initialize(self): |
217 | 392 | """See `IFeed`.""" | 392 | """See `IFeed`.""" |
218 | 393 | # For a `BranchFeed` we must ensure that the branch is not private. | 393 | # For a `BranchFeed` we must ensure that the branch is not private. |
220 | 394 | super(BranchFeed, self).initialize() | 394 | super().initialize() |
221 | 395 | try: | 395 | try: |
222 | 396 | feed_allowed = not self.context.private | 396 | feed_allowed = not self.context.private |
223 | 397 | if not feed_allowed: | 397 | if not feed_allowed: |
224 | diff --git a/lib/lp/code/interfaces/branch.py b/lib/lp/code/interfaces/branch.py | |||
225 | index e6d4e14..57d63e4 100644 | |||
226 | --- a/lib/lp/code/interfaces/branch.py | |||
227 | +++ b/lib/lp/code/interfaces/branch.py | |||
228 | @@ -281,7 +281,7 @@ class IBranchView(IHasOwner, IHasBranchTarget, IHasMergeProposals, | |||
229 | 281 | id = Int(title=_('ID'), readonly=True, required=True) | 281 | id = Int(title=_('ID'), readonly=True, required=True) |
230 | 282 | 282 | ||
231 | 283 | @operation_parameters( | 283 | @operation_parameters( |
233 | 284 | scheme=TextLine(title=_("URL scheme"), default=u'http')) | 284 | scheme=TextLine(title=_("URL scheme"), default='http')) |
234 | 285 | @export_read_operation() | 285 | @export_read_operation() |
235 | 286 | @operation_for_version('beta') | 286 | @operation_for_version('beta') |
236 | 287 | def composePublicURL(scheme='http'): | 287 | def composePublicURL(scheme='http'): |
237 | @@ -1376,11 +1376,11 @@ class IBranchSet(Interface): | |||
238 | 1376 | 1376 | ||
239 | 1377 | @operation_parameters( | 1377 | @operation_parameters( |
240 | 1378 | urls=List( | 1378 | urls=List( |
242 | 1379 | title=u'A list of URLs of branches', | 1379 | title='A list of URLs of branches', |
243 | 1380 | description=( | 1380 | description=( |
247 | 1381 | u'These can be URLs external to ' | 1381 | 'These can be URLs external to ' |
248 | 1382 | u'Launchpad, lp: URLs, or http://bazaar.launchpad.net/ URLs, ' | 1382 | 'Launchpad, lp: URLs, or http://bazaar.launchpad.net/ URLs, ' |
249 | 1383 | u'or any mix of all these different kinds.'), | 1383 | 'or any mix of all these different kinds.'), |
250 | 1384 | value_type=TextLine(), | 1384 | value_type=TextLine(), |
251 | 1385 | required=True)) | 1385 | required=True)) |
252 | 1386 | @export_read_operation() | 1386 | @export_read_operation() |
253 | diff --git a/lib/lp/code/interfaces/branchjob.py b/lib/lp/code/interfaces/branchjob.py | |||
254 | index 6ab861e..4f14416 100644 | |||
255 | --- a/lib/lp/code/interfaces/branchjob.py | |||
256 | +++ b/lib/lp/code/interfaces/branchjob.py | |||
257 | @@ -91,13 +91,13 @@ class IBranchUpgradeJobSource(IJobSource): | |||
258 | 91 | class IRevisionMailJob(IRunnableJob): | 91 | class IRevisionMailJob(IRunnableJob): |
259 | 92 | """A Job to send email a revision change in a branch.""" | 92 | """A Job to send email a revision change in a branch.""" |
260 | 93 | 93 | ||
262 | 94 | revno = Int(title=u'The revno to send mail about.') | 94 | revno = Int(title='The revno to send mail about.') |
263 | 95 | 95 | ||
265 | 96 | from_address = Bytes(title=u'The address to send mail from.') | 96 | from_address = Bytes(title='The address to send mail from.') |
266 | 97 | 97 | ||
268 | 98 | body = Text(title=u'The main text of the email to send.') | 98 | body = Text(title='The main text of the email to send.') |
269 | 99 | 99 | ||
271 | 100 | subject = Text(title=u'The subject of the email to send.') | 100 | subject = Text(title='The subject of the email to send.') |
272 | 101 | 101 | ||
273 | 102 | 102 | ||
274 | 103 | class IRevisionMailJobSource(IJobSource): | 103 | class IRevisionMailJobSource(IJobSource): |
275 | diff --git a/lib/lp/code/interfaces/codeimport.py b/lib/lp/code/interfaces/codeimport.py | |||
276 | index 7799e90..1a3e5a1 100644 | |||
277 | --- a/lib/lp/code/interfaces/codeimport.py | |||
278 | +++ b/lib/lp/code/interfaces/codeimport.py | |||
279 | @@ -55,7 +55,7 @@ class CVSRootError(Exception): | |||
280 | 55 | """Raised when trying to use a CVSROOT with invalid syntax.""" | 55 | """Raised when trying to use a CVSROOT with invalid syntax.""" |
281 | 56 | 56 | ||
282 | 57 | def __init__(self, root): | 57 | def __init__(self, root): |
284 | 58 | super(CVSRootError, self).__init__(self, 'bad CVSROOT: %r' % root) | 58 | super().__init__(self, 'bad CVSROOT: %r' % root) |
285 | 59 | 59 | ||
286 | 60 | 60 | ||
287 | 61 | _cvs_root_parser = re.compile(r""" | 61 | _cvs_root_parser = re.compile(r""" |
288 | diff --git a/lib/lp/code/interfaces/gitrepository.py b/lib/lp/code/interfaces/gitrepository.py | |||
289 | index aae1b90..d2d6a90 100644 | |||
290 | --- a/lib/lp/code/interfaces/gitrepository.py | |||
291 | +++ b/lib/lp/code/interfaces/gitrepository.py | |||
292 | @@ -832,7 +832,7 @@ class RevisionStatusReportsFeatureDisabled(Unauthorized): | |||
293 | 832 | """Only certain users can access APIs for revision status reports.""" | 832 | """Only certain users can access APIs for revision status reports.""" |
294 | 833 | 833 | ||
295 | 834 | def __init__(self): | 834 | def __init__(self): |
297 | 835 | super(RevisionStatusReportsFeatureDisabled, self).__init__( | 835 | super().__init__( |
298 | 836 | "You do not have permission to create revision status reports") | 836 | "You do not have permission to create revision status reports") |
299 | 837 | 837 | ||
300 | 838 | 838 | ||
301 | diff --git a/lib/lp/code/interfaces/sourcepackagerecipe.py b/lib/lp/code/interfaces/sourcepackagerecipe.py | |||
302 | index f954618..af05f7b 100644 | |||
303 | --- a/lib/lp/code/interfaces/sourcepackagerecipe.py | |||
304 | +++ b/lib/lp/code/interfaces/sourcepackagerecipe.py | |||
305 | @@ -69,13 +69,13 @@ from lp.services.fields import ( | |||
306 | 69 | from lp.soyuz.interfaces.archive import IArchive | 69 | from lp.soyuz.interfaces.archive import IArchive |
307 | 70 | 70 | ||
308 | 71 | 71 | ||
310 | 72 | MINIMAL_RECIPE_TEXT_BZR = dedent(u'''\ | 72 | MINIMAL_RECIPE_TEXT_BZR = dedent('''\ |
311 | 73 | # bzr-builder format 0.3 deb-version {debupstream}-0~{revno} | 73 | # bzr-builder format 0.3 deb-version {debupstream}-0~{revno} |
312 | 74 | %s | 74 | %s |
313 | 75 | ''') | 75 | ''') |
314 | 76 | 76 | ||
315 | 77 | 77 | ||
317 | 78 | MINIMAL_RECIPE_TEXT_GIT = dedent(u'''\ | 78 | MINIMAL_RECIPE_TEXT_GIT = dedent('''\ |
318 | 79 | # git-build-recipe format 0.4 deb-version {debupstream}-0~{revtime} | 79 | # git-build-recipe format 0.4 deb-version {debupstream}-0~{revtime} |
319 | 80 | %s %s | 80 | %s %s |
320 | 81 | ''') | 81 | ''') |
321 | diff --git a/lib/lp/code/mail/branch.py b/lib/lp/code/mail/branch.py | |||
322 | index c36a8b7..5de23f2 100644 | |||
323 | --- a/lib/lp/code/mail/branch.py | |||
324 | +++ b/lib/lp/code/mail/branch.py | |||
325 | @@ -58,8 +58,7 @@ class RecipientReason(basemailer.RecipientReason): | |||
326 | 58 | max_diff_lines=BranchSubscriptionDiffSize.WHOLEDIFF, | 58 | max_diff_lines=BranchSubscriptionDiffSize.WHOLEDIFF, |
327 | 59 | branch_identity_cache=None, | 59 | branch_identity_cache=None, |
328 | 60 | review_level=CodeReviewNotificationLevel.FULL): | 60 | review_level=CodeReviewNotificationLevel.FULL): |
331 | 61 | super(RecipientReason, self).__init__(subscriber, recipient, | 61 | super().__init__(subscriber, recipient, mail_header, reason_template) |
330 | 62 | mail_header, reason_template) | ||
332 | 63 | self.branch = branch | 62 | self.branch = branch |
333 | 64 | self.merge_proposal = merge_proposal | 63 | self.merge_proposal = merge_proposal |
334 | 65 | self.max_diff_lines = max_diff_lines | 64 | self.max_diff_lines = max_diff_lines |
335 | @@ -150,7 +149,7 @@ class RecipientReason(basemailer.RecipientReason): | |||
336 | 150 | branch_identity_cache=branch_identity_cache) | 149 | branch_identity_cache=branch_identity_cache) |
337 | 151 | 150 | ||
338 | 152 | def _getTemplateValues(self): | 151 | def _getTemplateValues(self): |
340 | 153 | template_values = super(RecipientReason, self)._getTemplateValues() | 152 | template_values = super()._getTemplateValues() |
341 | 154 | template_values['branch_name'] = self._getBranchIdentity(self.branch) | 153 | template_values['branch_name'] = self._getBranchIdentity(self.branch) |
342 | 155 | if self.merge_proposal is not None: | 154 | if self.merge_proposal is not None: |
343 | 156 | source = self._getBranchIdentity(self.merge_proposal.merge_source) | 155 | source = self._getBranchIdentity(self.merge_proposal.merge_source) |
344 | @@ -169,7 +168,7 @@ class BranchMailer(BaseMailer): | |||
345 | 169 | delta=None, delta_for_editors=None, contents=None, diff=None, | 168 | delta=None, delta_for_editors=None, contents=None, diff=None, |
346 | 170 | message_id=None, revno=None, revision_id=None, | 169 | message_id=None, revno=None, revision_id=None, |
347 | 171 | notification_type=None, **kwargs): | 170 | notification_type=None, **kwargs): |
349 | 172 | super(BranchMailer, self).__init__( | 171 | super().__init__( |
350 | 173 | subject, template_name, recipients, from_address, | 172 | subject, template_name, recipients, from_address, |
351 | 174 | message_id=message_id, notification_type=notification_type) | 173 | message_id=message_id, notification_type=notification_type) |
352 | 175 | self.delta_text = delta | 174 | self.delta_text = delta |
353 | diff --git a/lib/lp/code/mail/sourcepackagerecipebuild.py b/lib/lp/code/mail/sourcepackagerecipebuild.py | |||
354 | index 5b81714..a12452e 100644 | |||
355 | --- a/lib/lp/code/mail/sourcepackagerecipebuild.py | |||
356 | +++ b/lib/lp/code/mail/sourcepackagerecipebuild.py | |||
357 | @@ -42,8 +42,7 @@ class SourcePackageRecipeBuildMailer(BaseMailer): | |||
358 | 42 | 42 | ||
359 | 43 | def _getHeaders(self, email, recipient): | 43 | def _getHeaders(self, email, recipient): |
360 | 44 | """See `BaseMailer`""" | 44 | """See `BaseMailer`""" |
363 | 45 | headers = super( | 45 | headers = super()._getHeaders(email, recipient) |
362 | 46 | SourcePackageRecipeBuildMailer, self)._getHeaders(email, recipient) | ||
364 | 47 | headers.update({ | 46 | headers.update({ |
365 | 48 | 'X-Launchpad-Archive': self.build.archive.reference, | 47 | 'X-Launchpad-Archive': self.build.archive.reference, |
366 | 49 | 'X-Launchpad-Build-State': self.build.status.name, | 48 | 'X-Launchpad-Build-State': self.build.status.name, |
367 | @@ -52,9 +51,7 @@ class SourcePackageRecipeBuildMailer(BaseMailer): | |||
368 | 52 | 51 | ||
369 | 53 | def _getTemplateParams(self, email, recipient): | 52 | def _getTemplateParams(self, email, recipient): |
370 | 54 | """See `BaseMailer`""" | 53 | """See `BaseMailer`""" |
374 | 55 | params = super( | 54 | params = super()._getTemplateParams(email, recipient) |
372 | 56 | SourcePackageRecipeBuildMailer, self)._getTemplateParams( | ||
373 | 57 | email, recipient) | ||
375 | 58 | params.update({ | 55 | params.update({ |
376 | 59 | 'status': self.build.status.title, | 56 | 'status': self.build.status.title, |
377 | 60 | 'build_id': self.build.id, | 57 | 'build_id': self.build.id, |
378 | diff --git a/lib/lp/code/mail/tests/test_branch.py b/lib/lp/code/mail/tests/test_branch.py | |||
379 | index 69ed7dd..ee56593 100644 | |||
380 | --- a/lib/lp/code/mail/tests/test_branch.py | |||
381 | +++ b/lib/lp/code/mail/tests/test_branch.py | |||
382 | @@ -306,7 +306,7 @@ class TestBranchMailerDiffMixin: | |||
383 | 306 | 306 | ||
384 | 307 | def test_generateEmail_with_diff(self): | 307 | def test_generateEmail_with_diff(self): |
385 | 308 | """When there is a diff, it should be an attachment, not inline.""" | 308 | """When there is a diff, it should be an attachment, not inline.""" |
387 | 309 | ctrl = self.makeBobMailController(diff=u'hello \u03A3') | 309 | ctrl = self.makeBobMailController(diff='hello \u03A3') |
388 | 310 | self.assertEqual(1, len(ctrl.attachments)) | 310 | self.assertEqual(1, len(ctrl.attachments)) |
389 | 311 | diff = ctrl.attachments[0] | 311 | diff = ctrl.attachments[0] |
390 | 312 | self.assertEqual(b'hello \xce\xa3', diff.get_payload(decode=True)) | 312 | self.assertEqual(b'hello \xce\xa3', diff.get_payload(decode=True)) |
391 | diff --git a/lib/lp/code/mail/tests/test_branchmergeproposal.py b/lib/lp/code/mail/tests/test_branchmergeproposal.py | |||
392 | index 537918f..8e1e6f7 100644 | |||
393 | --- a/lib/lp/code/mail/tests/test_branchmergeproposal.py | |||
394 | +++ b/lib/lp/code/mail/tests/test_branchmergeproposal.py | |||
395 | @@ -57,7 +57,7 @@ class TestMergeProposalMailing(TestCaseWithFactory): | |||
396 | 57 | layer = LaunchpadZopelessLayer | 57 | layer = LaunchpadZopelessLayer |
397 | 58 | 58 | ||
398 | 59 | def setUp(self): | 59 | def setUp(self): |
400 | 60 | super(TestMergeProposalMailing, self).setUp('admin@canonical.com') | 60 | super().setUp('admin@canonical.com') |
401 | 61 | 61 | ||
402 | 62 | def makeProposalWithSubscriber(self, diff_text=None, initial_comment=None, | 62 | def makeProposalWithSubscriber(self, diff_text=None, initial_comment=None, |
403 | 63 | prerequisite=False, needs_review=True, | 63 | prerequisite=False, needs_review=True, |
404 | diff --git a/lib/lp/code/mail/tests/test_codehandler.py b/lib/lp/code/mail/tests/test_codehandler.py | |||
405 | index 21f8256..4788904 100644 | |||
406 | --- a/lib/lp/code/mail/tests/test_codehandler.py | |||
407 | +++ b/lib/lp/code/mail/tests/test_codehandler.py | |||
408 | @@ -129,13 +129,13 @@ class TestCodeHandler(TestCaseWithFactory): | |||
409 | 129 | layer = ZopelessAppServerLayer | 129 | layer = ZopelessAppServerLayer |
410 | 130 | 130 | ||
411 | 131 | def setUp(self): | 131 | def setUp(self): |
413 | 132 | super(TestCodeHandler, self).setUp(user='test@canonical.com') | 132 | super().setUp(user='test@canonical.com') |
414 | 133 | self.code_handler = CodeHandler() | 133 | self.code_handler = CodeHandler() |
415 | 134 | self._old_policy = setSecurityPolicy(LaunchpadSecurityPolicy) | 134 | self._old_policy = setSecurityPolicy(LaunchpadSecurityPolicy) |
416 | 135 | 135 | ||
417 | 136 | def tearDown(self): | 136 | def tearDown(self): |
418 | 137 | setSecurityPolicy(self._old_policy) | 137 | setSecurityPolicy(self._old_policy) |
420 | 138 | super(TestCodeHandler, self).tearDown() | 138 | super().tearDown() |
421 | 139 | 139 | ||
422 | 140 | def test_get(self): | 140 | def test_get(self): |
423 | 141 | handler = mail_handlers.get(config.launchpad.code_domain) | 141 | handler = mail_handlers.get(config.launchpad.code_domain) |
424 | @@ -453,7 +453,7 @@ class TestVoteEmailCommand(TestCase): | |||
425 | 453 | # We don't need no stinking layer. | 453 | # We don't need no stinking layer. |
426 | 454 | 454 | ||
427 | 455 | def setUp(self): | 455 | def setUp(self): |
429 | 456 | super(TestVoteEmailCommand, self).setUp() | 456 | super().setUp() |
430 | 457 | 457 | ||
431 | 458 | class FakeExecutionContext: | 458 | class FakeExecutionContext: |
432 | 459 | vote = None | 459 | vote = None |
433 | @@ -555,8 +555,7 @@ class TestUpdateStatusEmailCommand(TestCaseWithFactory): | |||
434 | 555 | layer = LaunchpadZopelessLayer | 555 | layer = LaunchpadZopelessLayer |
435 | 556 | 556 | ||
436 | 557 | def setUp(self): | 557 | def setUp(self): |
439 | 558 | super(TestUpdateStatusEmailCommand, self).setUp( | 558 | super().setUp(user='test@canonical.com') |
438 | 559 | user='test@canonical.com') | ||
440 | 560 | self._old_policy = setSecurityPolicy(LaunchpadSecurityPolicy) | 559 | self._old_policy = setSecurityPolicy(LaunchpadSecurityPolicy) |
441 | 561 | self.merge_proposal = self.factory.makeBranchMergeProposal() | 560 | self.merge_proposal = self.factory.makeBranchMergeProposal() |
442 | 562 | # Default the user to be the target branch owner, so they are | 561 | # Default the user to be the target branch owner, so they are |
443 | @@ -568,7 +567,7 @@ class TestUpdateStatusEmailCommand(TestCaseWithFactory): | |||
444 | 568 | 567 | ||
445 | 569 | def tearDown(self): | 568 | def tearDown(self): |
446 | 570 | setSecurityPolicy(self._old_policy) | 569 | setSecurityPolicy(self._old_policy) |
448 | 571 | super(TestUpdateStatusEmailCommand, self).tearDown() | 570 | super().tearDown() |
449 | 572 | 571 | ||
450 | 573 | def test_numberOfArguments(self): | 572 | def test_numberOfArguments(self): |
451 | 574 | # The command needs one and only one arg. | 573 | # The command needs one and only one arg. |
452 | @@ -678,8 +677,7 @@ class TestAddReviewerEmailCommand(TestCaseWithFactory): | |||
453 | 678 | layer = LaunchpadZopelessLayer | 677 | layer = LaunchpadZopelessLayer |
454 | 679 | 678 | ||
455 | 680 | def setUp(self): | 679 | def setUp(self): |
458 | 681 | super(TestAddReviewerEmailCommand, self).setUp( | 680 | super().setUp(user='test@canonical.com') |
457 | 682 | user='test@canonical.com') | ||
459 | 683 | self._old_policy = setSecurityPolicy(LaunchpadSecurityPolicy) | 681 | self._old_policy = setSecurityPolicy(LaunchpadSecurityPolicy) |
460 | 684 | self.merge_proposal = ( | 682 | self.merge_proposal = ( |
461 | 685 | make_merge_proposal_without_reviewers(self.factory)) | 683 | make_merge_proposal_without_reviewers(self.factory)) |
462 | @@ -692,7 +690,7 @@ class TestAddReviewerEmailCommand(TestCaseWithFactory): | |||
463 | 692 | 690 | ||
464 | 693 | def tearDown(self): | 691 | def tearDown(self): |
465 | 694 | setSecurityPolicy(self._old_policy) | 692 | setSecurityPolicy(self._old_policy) |
467 | 695 | super(TestAddReviewerEmailCommand, self).tearDown() | 693 | super().tearDown() |
468 | 696 | 694 | ||
469 | 697 | def test_numberOfArguments(self): | 695 | def test_numberOfArguments(self): |
470 | 698 | # The command needs at least one arg. | 696 | # The command needs at least one arg. |
471 | diff --git a/lib/lp/code/mail/tests/test_codeimport.py b/lib/lp/code/mail/tests/test_codeimport.py | |||
472 | index ee62761..77eefa5 100644 | |||
473 | --- a/lib/lp/code/mail/tests/test_codeimport.py | |||
474 | +++ b/lib/lp/code/mail/tests/test_codeimport.py | |||
475 | @@ -110,7 +110,7 @@ class TestNewCodeImports(TestCaseWithFactory): | |||
476 | 110 | login_person(eric) | 110 | login_person(eric) |
477 | 111 | self.factory.makeProductCodeImport( | 111 | self.factory.makeProductCodeImport( |
478 | 112 | git_repo_url='git://git.example.com/fooix.git', | 112 | git_repo_url='git://git.example.com/fooix.git', |
480 | 113 | branch_name=u'master', product=fooix, registrant=eric, | 113 | branch_name='master', product=fooix, registrant=eric, |
481 | 114 | target_rcs_type=TargetRevisionControlSystems.GIT) | 114 | target_rcs_type=TargetRevisionControlSystems.GIT) |
482 | 115 | transaction.commit() | 115 | transaction.commit() |
483 | 116 | msg = email.message_from_bytes(stub.test_emails[0][2]) | 116 | msg = email.message_from_bytes(stub.test_emails[0][2]) |
484 | diff --git a/lib/lp/code/mail/tests/test_sourcepackagerecipebuild.py b/lib/lp/code/mail/tests/test_sourcepackagerecipebuild.py | |||
485 | index b0f8f25..ed194e3 100644 | |||
486 | --- a/lib/lp/code/mail/tests/test_sourcepackagerecipebuild.py | |||
487 | +++ b/lib/lp/code/mail/tests/test_sourcepackagerecipebuild.py | |||
488 | @@ -16,7 +16,7 @@ from lp.testing.dbuser import switch_dbuser | |||
489 | 16 | from lp.testing.layers import LaunchpadZopelessLayer | 16 | from lp.testing.layers import LaunchpadZopelessLayer |
490 | 17 | 17 | ||
491 | 18 | 18 | ||
493 | 19 | expected_body = u"""\ | 19 | expected_body = """\ |
494 | 20 | * State: Successfully built | 20 | * State: Successfully built |
495 | 21 | * Recipe: person/recipe | 21 | * Recipe: person/recipe |
496 | 22 | * Archive: ~archiveowner/ubuntu/ppa | 22 | * Archive: ~archiveowner/ubuntu/ppa |
497 | @@ -27,7 +27,7 @@ expected_body = u"""\ | |||
498 | 27 | * Builder: http://launchpad.test/builders/bob | 27 | * Builder: http://launchpad.test/builders/bob |
499 | 28 | """ # noqa: W291 | 28 | """ # noqa: W291 |
500 | 29 | 29 | ||
502 | 30 | superseded_body = u"""\ | 30 | superseded_body = """\ |
503 | 31 | * State: Build for superseded Source | 31 | * State: Build for superseded Source |
504 | 32 | * Recipe: person/recipe | 32 | * Recipe: person/recipe |
505 | 33 | * Archive: ~archiveowner/ubuntu/ppa | 33 | * Archive: ~archiveowner/ubuntu/ppa |
506 | @@ -53,10 +53,10 @@ class TestSourcePackageRecipeBuildMailer(TestCaseWithFactory): | |||
507 | 53 | """GenerateEmail produces the right headers and body.""" | 53 | """GenerateEmail produces the right headers and body.""" |
508 | 54 | person = self.factory.makePerson(name='person') | 54 | person = self.factory.makePerson(name='person') |
509 | 55 | cake = self.factory.makeSourcePackageRecipe( | 55 | cake = self.factory.makeSourcePackageRecipe( |
511 | 56 | name=u'recipe', owner=person) | 56 | name='recipe', owner=person) |
512 | 57 | pantry_owner = self.factory.makePerson(name='archiveowner') | 57 | pantry_owner = self.factory.makePerson(name='archiveowner') |
513 | 58 | pantry = self.factory.makeArchive(name='ppa', owner=pantry_owner) | 58 | pantry = self.factory.makeArchive(name='ppa', owner=pantry_owner) |
515 | 59 | secret = self.factory.makeDistroSeries(name=u'distroseries') | 59 | secret = self.factory.makeDistroSeries(name='distroseries') |
516 | 60 | secret.nominatedarchindep = ( | 60 | secret.nominatedarchindep = ( |
517 | 61 | self.factory.makeDistroArchSeries(distroseries=secret)) | 61 | self.factory.makeDistroArchSeries(distroseries=secret)) |
518 | 62 | build = self.factory.makeSourcePackageRecipeBuild( | 62 | build = self.factory.makeSourcePackageRecipeBuild( |
519 | @@ -64,11 +64,11 @@ class TestSourcePackageRecipeBuildMailer(TestCaseWithFactory): | |||
520 | 64 | status=BuildStatus.FULLYBUILT, duration=timedelta(minutes=5)) | 64 | status=BuildStatus.FULLYBUILT, duration=timedelta(minutes=5)) |
521 | 65 | build.updateStatus( | 65 | build.updateStatus( |
522 | 66 | BuildStatus.FULLYBUILT, | 66 | BuildStatus.FULLYBUILT, |
524 | 67 | builder=self.factory.makeBuilder(name=u'bob')) | 67 | builder=self.factory.makeBuilder(name='bob')) |
525 | 68 | build.setLog(self.factory.makeLibraryFileAlias()) | 68 | build.setLog(self.factory.makeLibraryFileAlias()) |
526 | 69 | ctrl = self.makeStatusEmail(build) | 69 | ctrl = self.makeStatusEmail(build) |
527 | 70 | self.assertEqual( | 70 | self.assertEqual( |
529 | 71 | u'[recipe build #%d] of ~person recipe in distroseries: ' | 71 | '[recipe build #%d] of ~person recipe in distroseries: ' |
530 | 72 | 'Successfully built' % (build.id), ctrl.subject) | 72 | 'Successfully built' % (build.id), ctrl.subject) |
531 | 73 | body, footer = ctrl.body.split('\n-- \n') | 73 | body, footer = ctrl.body.split('\n-- \n') |
532 | 74 | self.assertEqual(expected_body % build.log_url, body) | 74 | self.assertEqual(expected_body % build.log_url, body) |
533 | @@ -93,10 +93,10 @@ class TestSourcePackageRecipeBuildMailer(TestCaseWithFactory): | |||
534 | 93 | """GenerateEmail works when many fields are NULL.""" | 93 | """GenerateEmail works when many fields are NULL.""" |
535 | 94 | person = self.factory.makePerson(name='person') | 94 | person = self.factory.makePerson(name='person') |
536 | 95 | cake = self.factory.makeSourcePackageRecipe( | 95 | cake = self.factory.makeSourcePackageRecipe( |
538 | 96 | name=u'recipe', owner=person) | 96 | name='recipe', owner=person) |
539 | 97 | pantry_owner = self.factory.makePerson(name='archiveowner') | 97 | pantry_owner = self.factory.makePerson(name='archiveowner') |
540 | 98 | pantry = self.factory.makeArchive(name='ppa', owner=pantry_owner) | 98 | pantry = self.factory.makeArchive(name='ppa', owner=pantry_owner) |
542 | 99 | secret = self.factory.makeDistroSeries(name=u'distroseries') | 99 | secret = self.factory.makeDistroSeries(name='distroseries') |
543 | 100 | secret.nominatedarchindep = ( | 100 | secret.nominatedarchindep = ( |
544 | 101 | self.factory.makeDistroArchSeries(distroseries=secret)) | 101 | self.factory.makeDistroArchSeries(distroseries=secret)) |
545 | 102 | build = self.factory.makeSourcePackageRecipeBuild( | 102 | build = self.factory.makeSourcePackageRecipeBuild( |
546 | @@ -105,7 +105,7 @@ class TestSourcePackageRecipeBuildMailer(TestCaseWithFactory): | |||
547 | 105 | Store.of(build).flush() | 105 | Store.of(build).flush() |
548 | 106 | ctrl = self.makeStatusEmail(build) | 106 | ctrl = self.makeStatusEmail(build) |
549 | 107 | self.assertEqual( | 107 | self.assertEqual( |
551 | 108 | u'[recipe build #%d] of ~person recipe in distroseries: ' | 108 | '[recipe build #%d] of ~person recipe in distroseries: ' |
552 | 109 | 'Build for superseded Source' % (build.id), ctrl.subject) | 109 | 'Build for superseded Source' % (build.id), ctrl.subject) |
553 | 110 | body, footer = ctrl.body.split('\n-- \n') | 110 | body, footer = ctrl.body.split('\n-- \n') |
554 | 111 | self.assertEqual(superseded_body, body) | 111 | self.assertEqual(superseded_body, body) |
555 | diff --git a/lib/lp/code/model/branch.py b/lib/lp/code/model/branch.py | |||
556 | index 1a9bcc4..98952be 100644 | |||
557 | --- a/lib/lp/code/model/branch.py | |||
558 | +++ b/lib/lp/code/model/branch.py | |||
559 | @@ -811,7 +811,7 @@ class Branch(SQLBase, WebhookTargetMixin, BzrIdentityMixin): | |||
560 | 811 | hosting_client = getUtility(IBranchHostingClient) | 811 | hosting_client = getUtility(IBranchHostingClient) |
561 | 812 | if enable_memcache is None: | 812 | if enable_memcache is None: |
562 | 813 | enable_memcache = not getFeatureFlag( | 813 | enable_memcache = not getFeatureFlag( |
564 | 814 | u'code.bzr.blob.disable_memcache') | 814 | 'code.bzr.blob.disable_memcache') |
565 | 815 | if revision_id is None: | 815 | if revision_id is None: |
566 | 816 | revision_id = self.last_scanned_id | 816 | revision_id = self.last_scanned_id |
567 | 817 | if revision_id is None: | 817 | if revision_id is None: |
568 | @@ -1138,7 +1138,7 @@ class Branch(SQLBase, WebhookTargetMixin, BzrIdentityMixin): | |||
569 | 1138 | 1138 | ||
570 | 1139 | def removeBranchRevisions(self, revision_ids): | 1139 | def removeBranchRevisions(self, revision_ids): |
571 | 1140 | """See `IBranch`.""" | 1140 | """See `IBranch`.""" |
573 | 1141 | if isinstance(revision_ids, six.string_types): | 1141 | if isinstance(revision_ids, str): |
574 | 1142 | revision_ids = [revision_ids] | 1142 | revision_ids = [revision_ids] |
575 | 1143 | IMasterStore(BranchRevision).find( | 1143 | IMasterStore(BranchRevision).find( |
576 | 1144 | BranchRevision, | 1144 | BranchRevision, |
577 | diff --git a/lib/lp/code/model/branchcollection.py b/lib/lp/code/model/branchcollection.py | |||
578 | index 6ba75ec..fe27bc6 100644 | |||
579 | --- a/lib/lp/code/model/branchcollection.py | |||
580 | +++ b/lib/lp/code/model/branchcollection.py | |||
581 | @@ -562,7 +562,7 @@ class GenericBranchCollection: | |||
582 | 562 | bugtasks_for_branch[bugbranch.branch].append(bugtask) | 562 | bugtasks_for_branch[bugbranch.branch].append(bugtask) |
583 | 563 | 563 | ||
584 | 564 | # Now filter those down to one bugtask per branch | 564 | # Now filter those down to one bugtask per branch |
586 | 565 | for branch, tasks in six.iteritems(bugtasks_for_branch): | 565 | for branch, tasks in bugtasks_for_branch.items(): |
587 | 566 | linked_bugtasks[branch.id].extend( | 566 | linked_bugtasks[branch.id].extend( |
588 | 567 | filter_bugtasks_by_context(branch.target.context, tasks)) | 567 | filter_bugtasks_by_context(branch.target.context, tasks)) |
589 | 568 | 568 | ||
590 | @@ -786,7 +786,7 @@ class VisibleBranchCollection(GenericBranchCollection): | |||
591 | 786 | def __init__(self, user, store=None, branch_filter_expressions=None, | 786 | def __init__(self, user, store=None, branch_filter_expressions=None, |
592 | 787 | tables=None, | 787 | tables=None, |
593 | 788 | asymmetric_filter_expressions=None, asymmetric_tables=None): | 788 | asymmetric_filter_expressions=None, asymmetric_tables=None): |
595 | 789 | super(VisibleBranchCollection, self).__init__( | 789 | super().__init__( |
596 | 790 | store=store, branch_filter_expressions=branch_filter_expressions, | 790 | store=store, branch_filter_expressions=branch_filter_expressions, |
597 | 791 | tables=tables, | 791 | tables=tables, |
598 | 792 | asymmetric_filter_expressions=asymmetric_filter_expressions, | 792 | asymmetric_filter_expressions=asymmetric_filter_expressions, |
599 | diff --git a/lib/lp/code/model/branchhosting.py b/lib/lp/code/model/branchhosting.py | |||
600 | index 58594e3..3911c16 100644 | |||
601 | --- a/lib/lp/code/model/branchhosting.py | |||
602 | +++ b/lib/lp/code/model/branchhosting.py | |||
603 | @@ -12,7 +12,6 @@ import sys | |||
604 | 12 | 12 | ||
605 | 13 | from lazr.restful.utils import get_current_browser_request | 13 | from lazr.restful.utils import get_current_browser_request |
606 | 14 | import requests | 14 | import requests |
607 | 15 | from six import reraise | ||
608 | 16 | from six.moves.urllib_parse import ( | 15 | from six.moves.urllib_parse import ( |
609 | 17 | quote, | 16 | quote, |
610 | 18 | urljoin, | 17 | urljoin, |
611 | @@ -72,9 +71,7 @@ class BranchHostingClient: | |||
612 | 72 | except Exception: | 71 | except Exception: |
613 | 73 | _, val, tb = sys.exc_info() | 72 | _, val, tb = sys.exc_info() |
614 | 74 | try: | 73 | try: |
618 | 75 | reraise( | 74 | raise RequestExceptionWrapper(*val.args).with_traceback(tb) |
616 | 76 | RequestExceptionWrapper, | ||
617 | 77 | RequestExceptionWrapper(*val.args), tb) | ||
619 | 78 | finally: | 75 | finally: |
620 | 79 | # Avoid traceback reference cycles. | 76 | # Avoid traceback reference cycles. |
621 | 80 | del val, tb | 77 | del val, tb |
622 | diff --git a/lib/lp/code/model/branchjob.py b/lib/lp/code/model/branchjob.py | |||
623 | index 5d7c0d8..aa06aeb 100644 | |||
624 | --- a/lib/lp/code/model/branchjob.py | |||
625 | +++ b/lib/lp/code/model/branchjob.py | |||
626 | @@ -227,7 +227,7 @@ class BranchJob(StormBase): | |||
627 | 227 | :param metadata: The type-specific variables, as a JSON-compatible | 227 | :param metadata: The type-specific variables, as a JSON-compatible |
628 | 228 | dict. | 228 | dict. |
629 | 229 | """ | 229 | """ |
631 | 230 | super(BranchJob, self).__init__() | 230 | super().__init__() |
632 | 231 | self.job = Job(**job_args) | 231 | self.job = Job(**job_args) |
633 | 232 | self.branch = branch | 232 | self.branch = branch |
634 | 233 | self.job_type = job_type | 233 | self.job_type = job_type |
635 | @@ -329,7 +329,7 @@ class BranchScanJob(BranchJobDerived): | |||
636 | 329 | return cls(branch_job) | 329 | return cls(branch_job) |
637 | 330 | 330 | ||
638 | 331 | def __init__(self, branch_job): | 331 | def __init__(self, branch_job): |
640 | 332 | super(BranchScanJob, self).__init__(branch_job) | 332 | super().__init__(branch_job) |
641 | 333 | self._cached_branch_name = self.metadata['branch_name'] | 333 | self._cached_branch_name = self.metadata['branch_name'] |
642 | 334 | 334 | ||
643 | 335 | @staticmethod | 335 | @staticmethod |
644 | @@ -507,7 +507,7 @@ class RevisionsAddedJob(BranchJobDerived): | |||
645 | 507 | return RevisionsAddedJob(branch_job) | 507 | return RevisionsAddedJob(branch_job) |
646 | 508 | 508 | ||
647 | 509 | def __init__(self, context): | 509 | def __init__(self, context): |
649 | 510 | super(RevisionsAddedJob, self).__init__(context) | 510 | super().__init__(context) |
650 | 511 | self._bzr_branch = None | 511 | self._bzr_branch = None |
651 | 512 | self._tree_cache = {} | 512 | self._tree_cache = {} |
652 | 513 | 513 | ||
653 | @@ -690,7 +690,7 @@ class RevisionsAddedJob(BranchJobDerived): | |||
654 | 690 | proposals[source_id] = (proposal, date_created) | 690 | proposals[source_id] = (proposal, date_created) |
655 | 691 | 691 | ||
656 | 692 | return sorted( | 692 | return sorted( |
658 | 693 | (proposal for proposal, date_created in six.itervalues(proposals)), | 693 | (proposal for proposal, date_created in proposals.values()), |
659 | 694 | key=operator.attrgetter('date_created'), reverse=True) | 694 | key=operator.attrgetter('date_created'), reverse=True) |
660 | 695 | 695 | ||
661 | 696 | def getRevisionMessage(self, revision_id, revno): | 696 | def getRevisionMessage(self, revision_id, revno): |
662 | @@ -763,7 +763,7 @@ class RosettaUploadJob(BranchJobDerived): | |||
663 | 763 | config = config.IRosettaUploadJobSource | 763 | config = config.IRosettaUploadJobSource |
664 | 764 | 764 | ||
665 | 765 | def __init__(self, branch_job): | 765 | def __init__(self, branch_job): |
667 | 766 | super(RosettaUploadJob, self).__init__(branch_job) | 766 | super().__init__(branch_job) |
668 | 767 | 767 | ||
669 | 768 | self.template_file_names = [] | 768 | self.template_file_names = [] |
670 | 769 | self.template_files_changed = [] | 769 | self.template_files_changed = [] |
671 | diff --git a/lib/lp/code/model/branchmergeproposal.py b/lib/lp/code/model/branchmergeproposal.py | |||
672 | index a0ff7d1..f0f23d7 100644 | |||
673 | --- a/lib/lp/code/model/branchmergeproposal.py | |||
674 | +++ b/lib/lp/code/model/branchmergeproposal.py | |||
675 | @@ -18,7 +18,6 @@ from lazr.lifecycle.event import ( | |||
676 | 18 | ObjectCreatedEvent, | 18 | ObjectCreatedEvent, |
677 | 19 | ObjectDeletedEvent, | 19 | ObjectDeletedEvent, |
678 | 20 | ) | 20 | ) |
679 | 21 | import six | ||
680 | 22 | from storm.expr import ( | 21 | from storm.expr import ( |
681 | 23 | And, | 22 | And, |
682 | 24 | Desc, | 23 | Desc, |
683 | @@ -392,8 +391,7 @@ class BranchMergeProposal(SQLBase, BugLinkTargetMixin): | |||
684 | 392 | else: | 391 | else: |
685 | 393 | bug_ids = [ | 392 | bug_ids = [ |
686 | 394 | int(id) for _, id in getUtility(IXRefSet).findFrom( | 393 | int(id) for _, id in getUtility(IXRefSet).findFrom( |
689 | 395 | (u'merge_proposal', six.text_type(self.id)), | 394 | ('merge_proposal', str(self.id)), types=['bug'])] |
688 | 396 | types=[u'bug'])] | ||
690 | 397 | bugs = load(Bug, bug_ids) | 395 | bugs = load(Bug, bug_ids) |
691 | 398 | return list(sorted(bugs, key=attrgetter('id'))) | 396 | return list(sorted(bugs, key=attrgetter('id'))) |
692 | 399 | 397 | ||
693 | @@ -420,14 +418,12 @@ class BranchMergeProposal(SQLBase, BugLinkTargetMixin): | |||
694 | 420 | props = {} | 418 | props = {} |
695 | 421 | # XXX cjwatson 2016-06-11: Should set creator. | 419 | # XXX cjwatson 2016-06-11: Should set creator. |
696 | 422 | getUtility(IXRefSet).create( | 420 | getUtility(IXRefSet).create( |
699 | 423 | {(u'merge_proposal', six.text_type(self.id)): | 421 | {('merge_proposal', str(self.id)): {('bug', str(bug.id)): props}}) |
698 | 424 | {(u'bug', six.text_type(bug.id)): props}}) | ||
700 | 425 | 422 | ||
701 | 426 | def deleteBugLink(self, bug): | 423 | def deleteBugLink(self, bug): |
702 | 427 | """See `BugLinkTargetMixin`.""" | 424 | """See `BugLinkTargetMixin`.""" |
703 | 428 | getUtility(IXRefSet).delete( | 425 | getUtility(IXRefSet).delete( |
706 | 429 | {(u'merge_proposal', six.text_type(self.id)): | 426 | {('merge_proposal', str(self.id)): [('bug', str(bug.id))]}) |
705 | 430 | [(u'bug', six.text_type(bug.id))]}) | ||
707 | 431 | 427 | ||
708 | 432 | def linkBug(self, bug, user=None, check_permissions=True, props=None): | 428 | def linkBug(self, bug, user=None, check_permissions=True, props=None): |
709 | 433 | """See `BugLinkTargetMixin`.""" | 429 | """See `BugLinkTargetMixin`.""" |
710 | @@ -436,7 +432,7 @@ class BranchMergeProposal(SQLBase, BugLinkTargetMixin): | |||
711 | 436 | return self.source_branch.linkBug(bug, user) | 432 | return self.source_branch.linkBug(bug, user) |
712 | 437 | else: | 433 | else: |
713 | 438 | # Otherwise, link the bug to the merge proposal directly. | 434 | # Otherwise, link the bug to the merge proposal directly. |
715 | 439 | return super(BranchMergeProposal, self).linkBug( | 435 | return super().linkBug( |
716 | 440 | bug, user=user, check_permissions=check_permissions, | 436 | bug, user=user, check_permissions=check_permissions, |
717 | 441 | props=props) | 437 | props=props) |
718 | 442 | 438 | ||
719 | @@ -451,7 +447,7 @@ class BranchMergeProposal(SQLBase, BugLinkTargetMixin): | |||
720 | 451 | return self.source_branch.unlinkBug(bug, user) | 447 | return self.source_branch.unlinkBug(bug, user) |
721 | 452 | else: | 448 | else: |
722 | 453 | # Otherwise, unlink the bug from the merge proposal directly. | 449 | # Otherwise, unlink the bug from the merge proposal directly. |
724 | 454 | return super(BranchMergeProposal, self).unlinkBug( | 450 | return super().unlinkBug( |
725 | 455 | bug, user=user, check_permissions=check_permissions) | 451 | bug, user=user, check_permissions=check_permissions) |
726 | 456 | 452 | ||
727 | 457 | def _reportTooManyRelatedBugs(self): | 453 | def _reportTooManyRelatedBugs(self): |
728 | @@ -505,8 +501,7 @@ class BranchMergeProposal(SQLBase, BugLinkTargetMixin): | |||
729 | 505 | current_bug_ids_from_source = { | 501 | current_bug_ids_from_source = { |
730 | 506 | int(id): (props['metadata'] or {}).get('from_source', False) | 502 | int(id): (props['metadata'] or {}).get('from_source', False) |
731 | 507 | for (_, id), props in getUtility(IXRefSet).findFrom( | 503 | for (_, id), props in getUtility(IXRefSet).findFrom( |
734 | 508 | (u'merge_proposal', six.text_type(self.id)), | 504 | ('merge_proposal', str(self.id)), types=['bug']).items()} |
733 | 509 | types=[u'bug']).items()} | ||
735 | 510 | current_bug_ids = set(current_bug_ids_from_source) | 505 | current_bug_ids = set(current_bug_ids_from_source) |
736 | 511 | new_bug_ids = self._fetchRelatedBugIDsFromSource() | 506 | new_bug_ids = self._fetchRelatedBugIDsFromSource() |
737 | 512 | # Only remove links marked as originating in the source branch. | 507 | # Only remove links marked as originating in the source branch. |
738 | diff --git a/lib/lp/code/model/branchmergeproposaljob.py b/lib/lp/code/model/branchmergeproposaljob.py | |||
739 | index 3a58ae9..8c1fd83 100644 | |||
740 | --- a/lib/lp/code/model/branchmergeproposaljob.py | |||
741 | +++ b/lib/lp/code/model/branchmergeproposaljob.py | |||
742 | @@ -175,7 +175,7 @@ class BranchMergeProposalJob(StormBase): | |||
743 | 175 | :param metadata: The type-specific variables, as a JSON-compatible | 175 | :param metadata: The type-specific variables, as a JSON-compatible |
744 | 176 | dict. | 176 | dict. |
745 | 177 | """ | 177 | """ |
747 | 178 | super(BranchMergeProposalJob, self).__init__() | 178 | super().__init__() |
748 | 179 | json_data = simplejson.dumps(metadata) | 179 | json_data = simplejson.dumps(metadata) |
749 | 180 | self.job = Job() | 180 | self.job = Job() |
750 | 181 | self.branch_merge_proposal = branch_merge_proposal | 181 | self.branch_merge_proposal = branch_merge_proposal |
751 | diff --git a/lib/lp/code/model/branchsubscription.py b/lib/lp/code/model/branchsubscription.py | |||
752 | index c9b10a8..36ec00a 100644 | |||
753 | --- a/lib/lp/code/model/branchsubscription.py | |||
754 | +++ b/lib/lp/code/model/branchsubscription.py | |||
755 | @@ -48,7 +48,7 @@ class BranchSubscription(StormBase): | |||
756 | 48 | 48 | ||
757 | 49 | def __init__(self, person, branch, notification_level, max_diff_lines, | 49 | def __init__(self, person, branch, notification_level, max_diff_lines, |
758 | 50 | review_level, subscribed_by): | 50 | review_level, subscribed_by): |
760 | 51 | super(BranchSubscription, self).__init__() | 51 | super().__init__() |
761 | 52 | self.person = person | 52 | self.person = person |
762 | 53 | self.branch = branch | 53 | self.branch = branch |
763 | 54 | self.notification_level = notification_level | 54 | self.notification_level = notification_level |
764 | diff --git a/lib/lp/code/model/branchtarget.py b/lib/lp/code/model/branchtarget.py | |||
765 | index 9100558..f341171 100644 | |||
766 | --- a/lib/lp/code/model/branchtarget.py | |||
767 | +++ b/lib/lp/code/model/branchtarget.py | |||
768 | @@ -187,7 +187,7 @@ class PackageBranchTarget(_BaseBranchTarget): | |||
769 | 187 | @implementer(IBranchTarget) | 187 | @implementer(IBranchTarget) |
770 | 188 | class PersonBranchTarget(_BaseBranchTarget): | 188 | class PersonBranchTarget(_BaseBranchTarget): |
771 | 189 | 189 | ||
773 | 190 | name = u'+junk' | 190 | name = '+junk' |
774 | 191 | default_stacked_on_branch = None | 191 | default_stacked_on_branch = None |
775 | 192 | default_merge_target = None | 192 | default_merge_target = None |
776 | 193 | 193 | ||
777 | diff --git a/lib/lp/code/model/codeimport.py b/lib/lp/code/model/codeimport.py | |||
778 | index c2b028e..13f6559 100644 | |||
779 | --- a/lib/lp/code/model/codeimport.py | |||
780 | +++ b/lib/lp/code/model/codeimport.py | |||
781 | @@ -83,7 +83,7 @@ class CodeImport(StormBase): | |||
782 | 83 | 83 | ||
783 | 84 | def __init__(self, registrant, owner, target, review_status, rcs_type=None, | 84 | def __init__(self, registrant, owner, target, review_status, rcs_type=None, |
784 | 85 | url=None, cvs_root=None, cvs_module=None): | 85 | url=None, cvs_root=None, cvs_module=None): |
786 | 86 | super(CodeImport, self).__init__() | 86 | super().__init__() |
787 | 87 | self.registrant = registrant | 87 | self.registrant = registrant |
788 | 88 | self.owner = owner | 88 | self.owner = owner |
789 | 89 | if IBranch.providedBy(target): | 89 | if IBranch.providedBy(target): |
790 | diff --git a/lib/lp/code/model/codeimportevent.py b/lib/lp/code/model/codeimportevent.py | |||
791 | index eb399d1..2b41ce4 100644 | |||
792 | --- a/lib/lp/code/model/codeimportevent.py | |||
793 | +++ b/lib/lp/code/model/codeimportevent.py | |||
794 | @@ -12,7 +12,6 @@ __all__ = [ | |||
795 | 12 | 12 | ||
796 | 13 | from lazr.enum import DBItem | 13 | from lazr.enum import DBItem |
797 | 14 | import pytz | 14 | import pytz |
798 | 15 | import six | ||
799 | 16 | from storm.locals import ( | 15 | from storm.locals import ( |
800 | 17 | DateTime, | 16 | DateTime, |
801 | 18 | Int, | 17 | Int, |
802 | @@ -65,7 +64,7 @@ class CodeImportEvent(StormBase): | |||
803 | 65 | 64 | ||
804 | 66 | def __init__(self, event_type, code_import=None, person=None, | 65 | def __init__(self, event_type, code_import=None, person=None, |
805 | 67 | machine=None, date_created=DEFAULT): | 66 | machine=None, date_created=DEFAULT): |
807 | 68 | super(CodeImportEvent, self).__init__() | 67 | super().__init__() |
808 | 69 | self.event_type = event_type | 68 | self.event_type = event_type |
809 | 70 | self.code_import = code_import | 69 | self.code_import = code_import |
810 | 71 | self.person = person | 70 | self.person = person |
811 | @@ -97,7 +96,7 @@ class _CodeImportEventData(StormBase): | |||
812 | 97 | data_value = Unicode(allow_none=True) | 96 | data_value = Unicode(allow_none=True) |
813 | 98 | 97 | ||
814 | 99 | def __init__(self, event, data_type, data_value): | 98 | def __init__(self, event, data_type, data_value): |
816 | 100 | super(_CodeImportEventData, self).__init__() | 99 | super().__init__() |
817 | 101 | self.event = event | 100 | self.event = event |
818 | 102 | self.data_type = data_type | 101 | self.data_type = data_type |
819 | 103 | self.data_value = data_value | 102 | self.data_value = data_value |
820 | @@ -200,7 +199,7 @@ class CodeImportEventSet: | |||
821 | 200 | IStore(CodeImportEvent).add(event) | 199 | IStore(CodeImportEvent).add(event) |
822 | 201 | IStore(_CodeImportEventData).add(_CodeImportEventData( | 200 | IStore(_CodeImportEventData).add(_CodeImportEventData( |
823 | 202 | event=event, data_type=CodeImportEventDataType.OFFLINE_REASON, | 201 | event=event, data_type=CodeImportEventDataType.OFFLINE_REASON, |
825 | 203 | data_value=six.text_type(reason.name))) | 202 | data_value=str(reason.name))) |
826 | 204 | self._recordMessage(event, message) | 203 | self._recordMessage(event, message) |
827 | 205 | return event | 204 | return event |
828 | 206 | 205 | ||
829 | @@ -257,7 +256,7 @@ class CodeImportEventSet: | |||
830 | 257 | IStore(CodeImportEvent).add(event) | 256 | IStore(CodeImportEvent).add(event) |
831 | 258 | IStore(_CodeImportEventData).add(_CodeImportEventData( | 257 | IStore(_CodeImportEventData).add(_CodeImportEventData( |
832 | 259 | event=event, data_type=CodeImportEventDataType.RECLAIMED_JOB_ID, | 258 | event=event, data_type=CodeImportEventDataType.RECLAIMED_JOB_ID, |
834 | 260 | data_value=six.text_type(job_id))) | 259 | data_value=str(job_id))) |
835 | 261 | return event | 260 | return event |
836 | 262 | 261 | ||
837 | 263 | def _recordSnapshot(self, event, code_import): | 262 | def _recordSnapshot(self, event, code_import): |
838 | @@ -278,18 +277,17 @@ class CodeImportEventSet: | |||
839 | 278 | def _iterItemsForSnapshot(self, code_import): | 277 | def _iterItemsForSnapshot(self, code_import): |
840 | 279 | """Yield key-value tuples to save a snapshot of the code import.""" | 278 | """Yield key-value tuples to save a snapshot of the code import.""" |
841 | 280 | yield self._getCodeImportItem(code_import) | 279 | yield self._getCodeImportItem(code_import) |
844 | 281 | yield 'REVIEW_STATUS', six.text_type(code_import.review_status.name) | 280 | yield 'REVIEW_STATUS', str(code_import.review_status.name) |
845 | 282 | yield 'OWNER', six.text_type(code_import.owner.id) | 281 | yield 'OWNER', str(code_import.owner.id) |
846 | 283 | yield 'UPDATE_INTERVAL', self._getNullableValue( | 282 | yield 'UPDATE_INTERVAL', self._getNullableValue( |
847 | 284 | code_import.update_interval) | 283 | code_import.update_interval) |
848 | 285 | yield 'ASSIGNEE', self._getNullableValue( | 284 | yield 'ASSIGNEE', self._getNullableValue( |
849 | 286 | code_import.assignee, use_id=True) | 285 | code_import.assignee, use_id=True) |
852 | 287 | for detail in self._iterSourceDetails(code_import): | 286 | yield from self._iterSourceDetails(code_import) |
851 | 288 | yield detail | ||
853 | 289 | 287 | ||
854 | 290 | def _getCodeImportItem(self, code_import): | 288 | def _getCodeImportItem(self, code_import): |
855 | 291 | """Return the key-value tuple for the code import id.""" | 289 | """Return the key-value tuple for the code import id.""" |
857 | 292 | return 'CODE_IMPORT', six.text_type(code_import.id) | 290 | return 'CODE_IMPORT', str(code_import.id) |
858 | 293 | 291 | ||
859 | 294 | def _getNullableValue(self, value, use_id=False): | 292 | def _getNullableValue(self, value, use_id=False): |
860 | 295 | """Return the string value for a nullable value. | 293 | """Return the string value for a nullable value. |
861 | @@ -301,9 +299,9 @@ class CodeImportEventSet: | |||
862 | 301 | if value is None: | 299 | if value is None: |
863 | 302 | return None | 300 | return None |
864 | 303 | elif use_id: | 301 | elif use_id: |
866 | 304 | return six.text_type(value.id) | 302 | return str(value.id) |
867 | 305 | else: | 303 | else: |
869 | 306 | return six.text_type(value) | 304 | return str(value) |
870 | 307 | 305 | ||
871 | 308 | def _iterSourceDetails(self, code_import): | 306 | def _iterSourceDetails(self, code_import): |
872 | 309 | """Yield key-value tuples describing the source of the import.""" | 307 | """Yield key-value tuples describing the source of the import.""" |
873 | diff --git a/lib/lp/code/model/codeimportjob.py b/lib/lp/code/model/codeimportjob.py | |||
874 | index a7839a3..0d010c5 100644 | |||
875 | --- a/lib/lp/code/model/codeimportjob.py | |||
876 | +++ b/lib/lp/code/model/codeimportjob.py | |||
877 | @@ -104,7 +104,7 @@ class CodeImportJob(StormBase): | |||
878 | 104 | date_started = DateTime(tzinfo=pytz.UTC, allow_none=True, default=None) | 104 | date_started = DateTime(tzinfo=pytz.UTC, allow_none=True, default=None) |
879 | 105 | 105 | ||
880 | 106 | def __init__(self, code_import, date_due): | 106 | def __init__(self, code_import, date_due): |
882 | 107 | super(CodeImportJob, self).__init__() | 107 | super().__init__() |
883 | 108 | self.code_import = code_import | 108 | self.code_import = code_import |
884 | 109 | self.date_due = date_due | 109 | self.date_due = date_due |
885 | 110 | 110 | ||
886 | @@ -179,7 +179,7 @@ class CodeImportJob(StormBase): | |||
887 | 179 | 179 | ||
888 | 180 | 180 | ||
889 | 181 | @implementer(ICodeImportJobSet, ICodeImportJobSetPublic) | 181 | @implementer(ICodeImportJobSet, ICodeImportJobSetPublic) |
891 | 182 | class CodeImportJobSet(object): | 182 | class CodeImportJobSet: |
892 | 183 | """See `ICodeImportJobSet`.""" | 183 | """See `ICodeImportJobSet`.""" |
893 | 184 | 184 | ||
894 | 185 | # CodeImportJob database objects are created using | 185 | # CodeImportJob database objects are created using |
895 | diff --git a/lib/lp/code/model/codeimportmachine.py b/lib/lp/code/model/codeimportmachine.py | |||
896 | index 084f8ca..0ce2fc5 100644 | |||
897 | --- a/lib/lp/code/model/codeimportmachine.py | |||
898 | +++ b/lib/lp/code/model/codeimportmachine.py | |||
899 | @@ -65,7 +65,7 @@ class CodeImportMachine(StormBase): | |||
900 | 65 | Desc('CodeImportEvent.id'))) | 65 | Desc('CodeImportEvent.id'))) |
901 | 66 | 66 | ||
902 | 67 | def __init__(self, hostname, heartbeat=None): | 67 | def __init__(self, hostname, heartbeat=None): |
904 | 68 | super(CodeImportMachine, self).__init__() | 68 | super().__init__() |
905 | 69 | self.hostname = hostname | 69 | self.hostname = hostname |
906 | 70 | self.heartbeat = heartbeat | 70 | self.heartbeat = heartbeat |
907 | 71 | self.state = CodeImportMachineState.OFFLINE | 71 | self.state = CodeImportMachineState.OFFLINE |
908 | @@ -120,7 +120,7 @@ class CodeImportMachine(StormBase): | |||
909 | 120 | 120 | ||
910 | 121 | 121 | ||
911 | 122 | @implementer(ICodeImportMachineSet) | 122 | @implementer(ICodeImportMachineSet) |
913 | 123 | class CodeImportMachineSet(object): | 123 | class CodeImportMachineSet: |
914 | 124 | """See `ICodeImportMachineSet`.""" | 124 | """See `ICodeImportMachineSet`.""" |
915 | 125 | 125 | ||
916 | 126 | def getAll(self): | 126 | def getAll(self): |
917 | diff --git a/lib/lp/code/model/codeimportresult.py b/lib/lp/code/model/codeimportresult.py | |||
918 | index 84fb963..222e3d6 100644 | |||
919 | --- a/lib/lp/code/model/codeimportresult.py | |||
920 | +++ b/lib/lp/code/model/codeimportresult.py | |||
921 | @@ -59,7 +59,7 @@ class CodeImportResult(StormBase): | |||
922 | 59 | def __init__(self, code_import, machine, status, date_job_started, | 59 | def __init__(self, code_import, machine, status, date_job_started, |
923 | 60 | requesting_user=None, log_excerpt=None, log_file=None, | 60 | requesting_user=None, log_excerpt=None, log_file=None, |
924 | 61 | date_created=UTC_NOW): | 61 | date_created=UTC_NOW): |
926 | 62 | super(CodeImportResult, self).__init__() | 62 | super().__init__() |
927 | 63 | self.code_import = code_import | 63 | self.code_import = code_import |
928 | 64 | self.machine = machine | 64 | self.machine = machine |
929 | 65 | self.status = status | 65 | self.status = status |
930 | @@ -80,7 +80,7 @@ class CodeImportResult(StormBase): | |||
931 | 80 | 80 | ||
932 | 81 | 81 | ||
933 | 82 | @implementer(ICodeImportResultSet) | 82 | @implementer(ICodeImportResultSet) |
935 | 83 | class CodeImportResultSet(object): | 83 | class CodeImportResultSet: |
936 | 84 | """See `ICodeImportResultSet`.""" | 84 | """See `ICodeImportResultSet`.""" |
937 | 85 | 85 | ||
938 | 86 | def new(self, code_import, machine, requesting_user, log_excerpt, | 86 | def new(self, code_import, machine, requesting_user, log_excerpt, |
939 | diff --git a/lib/lp/code/model/codereviewinlinecomment.py b/lib/lp/code/model/codereviewinlinecomment.py | |||
940 | index a6dc6da..a86d682 100644 | |||
941 | --- a/lib/lp/code/model/codereviewinlinecomment.py | |||
942 | +++ b/lib/lp/code/model/codereviewinlinecomment.py | |||
943 | @@ -9,7 +9,6 @@ __all__ = [ | |||
944 | 9 | 'CodeReviewInlineCommentSet', | 9 | 'CodeReviewInlineCommentSet', |
945 | 10 | ] | 10 | ] |
946 | 11 | 11 | ||
947 | 12 | import six | ||
948 | 13 | from storm.expr import LeftJoin | 12 | from storm.expr import LeftJoin |
949 | 14 | from storm.locals import ( | 13 | from storm.locals import ( |
950 | 15 | Int, | 14 | Int, |
951 | @@ -113,7 +112,7 @@ class CodeReviewInlineCommentSet: | |||
952 | 113 | list(crics), key=lambda c: c.comment.date_created) | 112 | list(crics), key=lambda c: c.comment.date_created) |
953 | 114 | inline_comments = [] | 113 | inline_comments = [] |
954 | 115 | for cric in sorted_crics: | 114 | for cric in sorted_crics: |
956 | 116 | for line_number, text in six.iteritems(cric.comments): | 115 | for line_number, text in cric.comments.items(): |
957 | 117 | comment = { | 116 | comment = { |
958 | 118 | 'line_number': line_number, | 117 | 'line_number': line_number, |
959 | 119 | 'person': cric.person, | 118 | 'person': cric.person, |
960 | diff --git a/lib/lp/code/model/diff.py b/lib/lp/code/model/diff.py | |||
961 | index 13f633c..93626b2 100644 | |||
962 | --- a/lib/lp/code/model/diff.py | |||
963 | +++ b/lib/lp/code/model/diff.py | |||
964 | @@ -98,7 +98,7 @@ class Diff(SQLBase): | |||
965 | 98 | @property | 98 | @property |
966 | 99 | def text(self): | 99 | def text(self): |
967 | 100 | if self.diff_text is None: | 100 | if self.diff_text is None: |
969 | 101 | return u'' | 101 | return '' |
970 | 102 | else: | 102 | else: |
971 | 103 | with reduced_timeout( | 103 | with reduced_timeout( |
972 | 104 | 0.01, webapp_max=2.0, | 104 | 0.01, webapp_max=2.0, |
973 | @@ -385,13 +385,13 @@ class PreviewDiff(Storm): | |||
974 | 385 | source_revision = bmp.source_branch.getBranchRevision( | 385 | source_revision = bmp.source_branch.getBranchRevision( |
975 | 386 | revision_id=self.source_revision_id) | 386 | revision_id=self.source_revision_id) |
976 | 387 | if source_revision and source_revision.sequence: | 387 | if source_revision and source_revision.sequence: |
978 | 388 | source_rev = u'r{}'.format(source_revision.sequence) | 388 | source_rev = 'r{}'.format(source_revision.sequence) |
979 | 389 | else: | 389 | else: |
980 | 390 | source_rev = self.source_revision_id | 390 | source_rev = self.source_revision_id |
981 | 391 | target_revision = bmp.target_branch.getBranchRevision( | 391 | target_revision = bmp.target_branch.getBranchRevision( |
982 | 392 | revision_id=self.target_revision_id) | 392 | revision_id=self.target_revision_id) |
983 | 393 | if target_revision and target_revision.sequence: | 393 | if target_revision and target_revision.sequence: |
985 | 394 | target_rev = u'r{}'.format(target_revision.sequence) | 394 | target_rev = 'r{}'.format(target_revision.sequence) |
986 | 395 | else: | 395 | else: |
987 | 396 | target_rev = self.target_revision_id | 396 | target_rev = self.target_revision_id |
988 | 397 | else: | 397 | else: |
989 | @@ -402,7 +402,7 @@ class PreviewDiff(Storm): | |||
990 | 402 | source_rev = self.source_revision_id[:7] | 402 | source_rev = self.source_revision_id[:7] |
991 | 403 | target_rev = self.target_revision_id[:7] | 403 | target_rev = self.target_revision_id[:7] |
992 | 404 | 404 | ||
994 | 405 | return u'{} into {}'.format(source_rev, target_rev) | 405 | return '{} into {}'.format(source_rev, target_rev) |
995 | 406 | 406 | ||
996 | 407 | @property | 407 | @property |
997 | 408 | def has_conflicts(self): | 408 | def has_conflicts(self): |
998 | @@ -433,8 +433,8 @@ class PreviewDiff(Storm): | |||
999 | 433 | preview.target_revision_id = target_revision.decode('utf-8') | 433 | preview.target_revision_id = target_revision.decode('utf-8') |
1000 | 434 | preview.branch_merge_proposal = bmp | 434 | preview.branch_merge_proposal = bmp |
1001 | 435 | preview.diff = diff | 435 | preview.diff = diff |
1004 | 436 | preview.conflicts = u''.join( | 436 | preview.conflicts = ''.join( |
1005 | 437 | six.text_type(conflict) + '\n' for conflict in conflicts) | 437 | str(conflict) + '\n' for conflict in conflicts) |
1006 | 438 | else: | 438 | else: |
1007 | 439 | source_repository = bmp.source_git_repository | 439 | source_repository = bmp.source_git_repository |
1008 | 440 | target_repository = bmp.target_git_repository | 440 | target_repository = bmp.target_git_repository |
1009 | @@ -449,8 +449,8 @@ class PreviewDiff(Storm): | |||
1010 | 449 | response = getUtility(IGitHostingClient).getMergeDiff( | 449 | response = getUtility(IGitHostingClient).getMergeDiff( |
1011 | 450 | path, bmp.target_git_commit_sha1, bmp.source_git_commit_sha1, | 450 | path, bmp.target_git_commit_sha1, bmp.source_git_commit_sha1, |
1012 | 451 | prerequisite=bmp.prerequisite_git_commit_sha1) | 451 | prerequisite=bmp.prerequisite_git_commit_sha1) |
1015 | 452 | conflicts = u"".join( | 452 | conflicts = "".join( |
1016 | 453 | u"Conflict in %s\n" % path for path in response['conflicts']) | 453 | "Conflict in %s\n" % path for path in response['conflicts']) |
1017 | 454 | preview = cls.create( | 454 | preview = cls.create( |
1018 | 455 | bmp, response['patch'].encode('utf-8'), | 455 | bmp, response['patch'].encode('utf-8'), |
1019 | 456 | bmp.source_git_commit_sha1, bmp.target_git_commit_sha1, | 456 | bmp.source_git_commit_sha1, bmp.target_git_commit_sha1, |
1020 | diff --git a/lib/lp/code/model/gitactivity.py b/lib/lp/code/model/gitactivity.py | |||
1021 | index a7b2036..42091f1 100644 | |||
1022 | --- a/lib/lp/code/model/gitactivity.py | |||
1023 | +++ b/lib/lp/code/model/gitactivity.py | |||
1024 | @@ -60,7 +60,7 @@ class GitActivity(StormBase): | |||
1025 | 60 | 60 | ||
1026 | 61 | def __init__(self, repository, changer, what_changed, changee=None, | 61 | def __init__(self, repository, changer, what_changed, changee=None, |
1027 | 62 | old_value=None, new_value=None, date_changed=DEFAULT): | 62 | old_value=None, new_value=None, date_changed=DEFAULT): |
1029 | 63 | super(GitActivity, self).__init__() | 63 | super().__init__() |
1030 | 64 | self.repository = repository | 64 | self.repository = repository |
1031 | 65 | self.date_changed = date_changed | 65 | self.date_changed = date_changed |
1032 | 66 | self.changer = changer | 66 | self.changer = changer |
1033 | diff --git a/lib/lp/code/model/gitcollection.py b/lib/lp/code/model/gitcollection.py | |||
1034 | index 966ea02..8c2d4f1 100644 | |||
1035 | --- a/lib/lp/code/model/gitcollection.py | |||
1036 | +++ b/lib/lp/code/model/gitcollection.py | |||
1037 | @@ -622,7 +622,7 @@ class VisibleGitCollection(GenericGitCollection): | |||
1038 | 622 | 622 | ||
1039 | 623 | def __init__(self, user, store=None, filter_expressions=None, tables=None, | 623 | def __init__(self, user, store=None, filter_expressions=None, tables=None, |
1040 | 624 | asymmetric_filter_expressions=None, asymmetric_tables=None): | 624 | asymmetric_filter_expressions=None, asymmetric_tables=None): |
1042 | 625 | super(VisibleGitCollection, self).__init__( | 625 | super().__init__( |
1043 | 626 | store=store, filter_expressions=filter_expressions, tables=tables, | 626 | store=store, filter_expressions=filter_expressions, tables=tables, |
1044 | 627 | asymmetric_filter_expressions=asymmetric_filter_expressions, | 627 | asymmetric_filter_expressions=asymmetric_filter_expressions, |
1045 | 628 | asymmetric_tables=asymmetric_tables) | 628 | asymmetric_tables=asymmetric_tables) |
1046 | diff --git a/lib/lp/code/model/githosting.py b/lib/lp/code/model/githosting.py | |||
1047 | index 6494390..e498138 100644 | |||
1048 | --- a/lib/lp/code/model/githosting.py | |||
1049 | +++ b/lib/lp/code/model/githosting.py | |||
1050 | @@ -14,11 +14,7 @@ import sys | |||
1051 | 14 | 14 | ||
1052 | 15 | from lazr.restful.utils import get_current_browser_request | 15 | from lazr.restful.utils import get_current_browser_request |
1053 | 16 | import requests | 16 | import requests |
1059 | 17 | import six | 17 | from six import ensure_text |
1055 | 18 | from six import ( | ||
1056 | 19 | ensure_text, | ||
1057 | 20 | reraise, | ||
1058 | 21 | ) | ||
1060 | 22 | from six.moves.urllib.parse import ( | 18 | from six.moves.urllib.parse import ( |
1061 | 23 | quote, | 19 | quote, |
1062 | 24 | urljoin, | 20 | urljoin, |
1063 | @@ -89,9 +85,7 @@ class GitHostingClient: | |||
1064 | 89 | except Exception: | 85 | except Exception: |
1065 | 90 | _, val, tb = sys.exc_info() | 86 | _, val, tb = sys.exc_info() |
1066 | 91 | try: | 87 | try: |
1070 | 92 | reraise( | 88 | raise RequestExceptionWrapper(*val.args).with_traceback(tb) |
1068 | 93 | RequestExceptionWrapper, | ||
1069 | 94 | RequestExceptionWrapper(*val.args), tb) | ||
1071 | 95 | finally: | 89 | finally: |
1072 | 96 | # Avoid traceback reference cycles. | 90 | # Avoid traceback reference cycles. |
1073 | 97 | del val, tb | 91 | del val, tb |
1074 | @@ -131,7 +125,7 @@ class GitHostingClient: | |||
1075 | 131 | self._post("/repo", json=request) | 125 | self._post("/repo", json=request) |
1076 | 132 | except requests.RequestException as e: | 126 | except requests.RequestException as e: |
1077 | 133 | raise GitRepositoryCreationFault( | 127 | raise GitRepositoryCreationFault( |
1079 | 134 | "Failed to create Git repository: %s" % six.text_type(e), path) | 128 | "Failed to create Git repository: %s" % str(e), path) |
1080 | 135 | 129 | ||
1081 | 136 | def getProperties(self, path): | 130 | def getProperties(self, path): |
1082 | 137 | """See `IGitHostingClient`.""" | 131 | """See `IGitHostingClient`.""" |
1083 | @@ -139,8 +133,7 @@ class GitHostingClient: | |||
1084 | 139 | return self._get("/repo/%s" % path) | 133 | return self._get("/repo/%s" % path) |
1085 | 140 | except requests.RequestException as e: | 134 | except requests.RequestException as e: |
1086 | 141 | raise GitRepositoryScanFault( | 135 | raise GitRepositoryScanFault( |
1089 | 142 | "Failed to get properties of Git repository: %s" % | 136 | "Failed to get properties of Git repository: %s" % str(e)) |
1088 | 143 | six.text_type(e)) | ||
1090 | 144 | 137 | ||
1091 | 145 | def setProperties(self, path, **props): | 138 | def setProperties(self, path, **props): |
1092 | 146 | """See `IGitHostingClient`.""" | 139 | """See `IGitHostingClient`.""" |
1093 | @@ -148,8 +141,7 @@ class GitHostingClient: | |||
1094 | 148 | self._patch("/repo/%s" % path, json=props) | 141 | self._patch("/repo/%s" % path, json=props) |
1095 | 149 | except requests.RequestException as e: | 142 | except requests.RequestException as e: |
1096 | 150 | raise GitRepositoryScanFault( | 143 | raise GitRepositoryScanFault( |
1099 | 151 | "Failed to set properties of Git repository: %s" % | 144 | "Failed to set properties of Git repository: %s" % str(e)) |
1098 | 152 | six.text_type(e)) | ||
1100 | 153 | 145 | ||
1101 | 154 | def getRefs(self, path, exclude_prefixes=None): | 146 | def getRefs(self, path, exclude_prefixes=None): |
1102 | 155 | """See `IGitHostingClient`.""" | 147 | """See `IGitHostingClient`.""" |
1103 | @@ -159,8 +151,7 @@ class GitHostingClient: | |||
1104 | 159 | params={"exclude_prefix": exclude_prefixes}) | 151 | params={"exclude_prefix": exclude_prefixes}) |
1105 | 160 | except requests.RequestException as e: | 152 | except requests.RequestException as e: |
1106 | 161 | raise GitRepositoryScanFault( | 153 | raise GitRepositoryScanFault( |
1109 | 162 | "Failed to get refs from Git repository: %s" % | 154 | "Failed to get refs from Git repository: %s" % str(e)) |
1108 | 163 | six.text_type(e)) | ||
1110 | 164 | 155 | ||
1111 | 165 | def getCommits(self, path, commit_oids, logger=None): | 156 | def getCommits(self, path, commit_oids, logger=None): |
1112 | 166 | """See `IGitHostingClient`.""" | 157 | """See `IGitHostingClient`.""" |
1113 | @@ -173,7 +164,7 @@ class GitHostingClient: | |||
1114 | 173 | except requests.RequestException as e: | 164 | except requests.RequestException as e: |
1115 | 174 | raise GitRepositoryScanFault( | 165 | raise GitRepositoryScanFault( |
1116 | 175 | "Failed to get commit details from Git repository: %s" % | 166 | "Failed to get commit details from Git repository: %s" % |
1118 | 176 | six.text_type(e)) | 167 | str(e)) |
1119 | 177 | 168 | ||
1120 | 178 | def getLog(self, path, start, limit=None, stop=None, logger=None): | 169 | def getLog(self, path, start, limit=None, stop=None, logger=None): |
1121 | 179 | """See `IGitHostingClient`.""" | 170 | """See `IGitHostingClient`.""" |
1122 | @@ -188,8 +179,7 @@ class GitHostingClient: | |||
1123 | 188 | params={"limit": limit, "stop": stop}) | 179 | params={"limit": limit, "stop": stop}) |
1124 | 189 | except requests.RequestException as e: | 180 | except requests.RequestException as e: |
1125 | 190 | raise GitRepositoryScanFault( | 181 | raise GitRepositoryScanFault( |
1128 | 191 | "Failed to get commit log from Git repository: %s" % | 182 | "Failed to get commit log from Git repository: %s" % str(e)) |
1127 | 192 | six.text_type(e)) | ||
1129 | 193 | 183 | ||
1130 | 194 | def getDiff(self, path, old, new, common_ancestor=False, | 184 | def getDiff(self, path, old, new, common_ancestor=False, |
1131 | 195 | context_lines=None, logger=None): | 185 | context_lines=None, logger=None): |
1132 | @@ -204,8 +194,7 @@ class GitHostingClient: | |||
1133 | 204 | return self._get(url, params={"context_lines": context_lines}) | 194 | return self._get(url, params={"context_lines": context_lines}) |
1134 | 205 | except requests.RequestException as e: | 195 | except requests.RequestException as e: |
1135 | 206 | raise GitRepositoryScanFault( | 196 | raise GitRepositoryScanFault( |
1138 | 207 | "Failed to get diff from Git repository: %s" % | 197 | "Failed to get diff from Git repository: %s" % str(e)) |
1137 | 208 | six.text_type(e)) | ||
1139 | 209 | 198 | ||
1140 | 210 | def getMergeDiff(self, path, base, head, prerequisite=None, logger=None): | 199 | def getMergeDiff(self, path, base, head, prerequisite=None, logger=None): |
1141 | 211 | """See `IGitHostingClient`.""" | 200 | """See `IGitHostingClient`.""" |
1142 | @@ -219,8 +208,7 @@ class GitHostingClient: | |||
1143 | 219 | return self._get(url, params={"sha1_prerequisite": prerequisite}) | 208 | return self._get(url, params={"sha1_prerequisite": prerequisite}) |
1144 | 220 | except requests.RequestException as e: | 209 | except requests.RequestException as e: |
1145 | 221 | raise GitRepositoryScanFault( | 210 | raise GitRepositoryScanFault( |
1148 | 222 | "Failed to get merge diff from Git repository: %s" % | 211 | "Failed to get merge diff from Git repository: %s" % str(e)) |
1147 | 223 | six.text_type(e)) | ||
1149 | 224 | 212 | ||
1150 | 225 | def detectMerges(self, path, target, sources, logger=None): | 213 | def detectMerges(self, path, target, sources, logger=None): |
1151 | 226 | """See `IGitHostingClient`.""" | 214 | """See `IGitHostingClient`.""" |
1152 | @@ -235,8 +223,7 @@ class GitHostingClient: | |||
1153 | 235 | json={"sources": sources}) | 223 | json={"sources": sources}) |
1154 | 236 | except requests.RequestException as e: | 224 | except requests.RequestException as e: |
1155 | 237 | raise GitRepositoryScanFault( | 225 | raise GitRepositoryScanFault( |
1158 | 238 | "Failed to detect merges in Git repository: %s" % | 226 | "Failed to detect merges in Git repository: %s" % str(e)) |
1157 | 239 | six.text_type(e)) | ||
1159 | 240 | 227 | ||
1160 | 241 | def delete(self, path, logger=None): | 228 | def delete(self, path, logger=None): |
1161 | 242 | """See `IGitHostingClient`.""" | 229 | """See `IGitHostingClient`.""" |
1162 | @@ -246,7 +233,7 @@ class GitHostingClient: | |||
1163 | 246 | self._delete("/repo/%s" % path) | 233 | self._delete("/repo/%s" % path) |
1164 | 247 | except requests.RequestException as e: | 234 | except requests.RequestException as e: |
1165 | 248 | raise GitRepositoryDeletionFault( | 235 | raise GitRepositoryDeletionFault( |
1167 | 249 | "Failed to delete Git repository: %s" % six.text_type(e)) | 236 | "Failed to delete Git repository: %s" % str(e)) |
1168 | 250 | 237 | ||
1169 | 251 | def getBlob(self, path, filename, rev=None, logger=None): | 238 | def getBlob(self, path, filename, rev=None, logger=None): |
1170 | 252 | """See `IGitHostingClient`.""" | 239 | """See `IGitHostingClient`.""" |
1171 | @@ -262,8 +249,7 @@ class GitHostingClient: | |||
1172 | 262 | raise GitRepositoryBlobNotFound(path, filename, rev=rev) | 249 | raise GitRepositoryBlobNotFound(path, filename, rev=rev) |
1173 | 263 | else: | 250 | else: |
1174 | 264 | raise GitRepositoryScanFault( | 251 | raise GitRepositoryScanFault( |
1177 | 265 | "Failed to get file from Git repository: %s" % | 252 | "Failed to get file from Git repository: %s" % str(e)) |
1176 | 266 | six.text_type(e)) | ||
1178 | 267 | try: | 253 | try: |
1179 | 268 | blob = base64.b64decode(response["data"].encode("UTF-8")) | 254 | blob = base64.b64decode(response["data"].encode("UTF-8")) |
1180 | 269 | if len(blob) != response["size"]: | 255 | if len(blob) != response["size"]: |
1181 | @@ -273,8 +259,7 @@ class GitHostingClient: | |||
1182 | 273 | return blob | 259 | return blob |
1183 | 274 | except Exception as e: | 260 | except Exception as e: |
1184 | 275 | raise GitRepositoryScanFault( | 261 | raise GitRepositoryScanFault( |
1187 | 276 | "Failed to get file from Git repository: %s" % | 262 | "Failed to get file from Git repository: %s" % str(e)) |
1186 | 277 | six.text_type(e)) | ||
1188 | 278 | 263 | ||
1189 | 279 | def copyRefs(self, path, operations, logger=None): | 264 | def copyRefs(self, path, operations, logger=None): |
1190 | 280 | """See `IGitHostingClient`.""" | 265 | """See `IGitHostingClient`.""" |
1191 | @@ -334,7 +319,7 @@ class GitHostingClient: | |||
1192 | 334 | else: | 319 | else: |
1193 | 335 | raise CannotRepackRepository( | 320 | raise CannotRepackRepository( |
1194 | 336 | "Failed to repack Git repository %s: %s" % | 321 | "Failed to repack Git repository %s: %s" % |
1196 | 337 | (path, six.text_type(e))) | 322 | (path, str(e))) |
1197 | 338 | 323 | ||
1198 | 339 | def collectGarbage(self, path, logger=None): | 324 | def collectGarbage(self, path, logger=None): |
1199 | 340 | """See `IGitHostingClient`.""" | 325 | """See `IGitHostingClient`.""" |
1200 | @@ -349,4 +334,4 @@ class GitHostingClient: | |||
1201 | 349 | except requests.RequestException as e: | 334 | except requests.RequestException as e: |
1202 | 350 | raise CannotRunGitGC( | 335 | raise CannotRunGitGC( |
1203 | 351 | "Failed to run Git GC for repository %s: %s" % | 336 | "Failed to run Git GC for repository %s: %s" % |
1205 | 352 | (path, six.text_type(e))) | 337 | (path, str(e))) |
1206 | diff --git a/lib/lp/code/model/gitjob.py b/lib/lp/code/model/gitjob.py | |||
1207 | index 2e78d06..8b0ede0 100644 | |||
1208 | --- a/lib/lp/code/model/gitjob.py | |||
1209 | +++ b/lib/lp/code/model/gitjob.py | |||
1210 | @@ -125,7 +125,7 @@ class GitJob(StormBase): | |||
1211 | 125 | :param metadata: The type-specific variables, as a JSON-compatible | 125 | :param metadata: The type-specific variables, as a JSON-compatible |
1212 | 126 | dict. | 126 | dict. |
1213 | 127 | """ | 127 | """ |
1215 | 128 | super(GitJob, self).__init__() | 128 | super().__init__() |
1216 | 129 | self.job = Job(**job_args) | 129 | self.job = Job(**job_args) |
1217 | 130 | self.repository = repository | 130 | self.repository = repository |
1218 | 131 | self.job_type = job_type | 131 | self.job_type = job_type |
1219 | @@ -177,7 +177,7 @@ class GitJobDerived(BaseRunnableJob, metaclass=EnumeratedSubclass): | |||
1220 | 177 | 177 | ||
1221 | 178 | def getOopsVars(self): | 178 | def getOopsVars(self): |
1222 | 179 | """See `IRunnableJob`.""" | 179 | """See `IRunnableJob`.""" |
1224 | 180 | oops_vars = super(GitJobDerived, self).getOopsVars() | 180 | oops_vars = super().getOopsVars() |
1225 | 181 | oops_vars.extend([ | 181 | oops_vars.extend([ |
1226 | 182 | ('git_job_id', self.context.job.id), | 182 | ('git_job_id', self.context.job.id), |
1227 | 183 | ('git_job_type', self.context.job_type.title), | 183 | ('git_job_type', self.context.job_type.title), |
1228 | diff --git a/lib/lp/code/model/gitlookup.py b/lib/lp/code/model/gitlookup.py | |||
1229 | index 03b5a43..6c5746f 100644 | |||
1230 | --- a/lib/lp/code/model/gitlookup.py | |||
1231 | +++ b/lib/lp/code/model/gitlookup.py | |||
1232 | @@ -151,8 +151,7 @@ class ProjectGitTraversable(_BaseGitTraversable): | |||
1233 | 151 | if oci_project is None: | 151 | if oci_project is None: |
1234 | 152 | raise NoSuchOCIProjectName(ociproject_name) | 152 | raise NoSuchOCIProjectName(ociproject_name) |
1235 | 153 | return owner, oci_project, None | 153 | return owner, oci_project, None |
1238 | 154 | return super(ProjectGitTraversable, self).traverse( | 154 | return super().traverse(owner, name, segments) |
1237 | 155 | owner, name, segments) | ||
1239 | 156 | 155 | ||
1240 | 157 | def getNamespace(self, owner): | 156 | def getNamespace(self, owner): |
1241 | 158 | return getUtility(IGitNamespaceSet).get(owner, project=self.context) | 157 | return getUtility(IGitNamespaceSet).get(owner, project=self.context) |
1242 | @@ -240,8 +239,7 @@ class PersonGitTraversable(_BaseGitTraversable): | |||
1243 | 240 | `IGitRepository`). | 239 | `IGitRepository`). |
1244 | 241 | """ | 240 | """ |
1245 | 242 | if name == "+git": | 241 | if name == "+git": |
1248 | 243 | return super(PersonGitTraversable, self).traverse( | 242 | return super().traverse(owner, name, segments) |
1247 | 244 | owner, name, segments) | ||
1249 | 245 | else: | 243 | else: |
1250 | 246 | if not valid_name(name): | 244 | if not valid_name(name): |
1251 | 247 | raise InvalidProductName(name) | 245 | raise InvalidProductName(name) |
1252 | @@ -266,7 +264,7 @@ class DistributionOCIProjectGitTraversable(_BaseGitTraversable): | |||
1253 | 266 | owner, oci_project=self.context) | 264 | owner, oci_project=self.context) |
1254 | 267 | 265 | ||
1255 | 268 | 266 | ||
1257 | 269 | class SegmentIterator(six.Iterator): | 267 | class SegmentIterator: |
1258 | 270 | """An iterator that remembers the elements it has traversed.""" | 268 | """An iterator that remembers the elements it has traversed.""" |
1259 | 271 | 269 | ||
1260 | 272 | def __init__(self, iterator): | 270 | def __init__(self, iterator): |
1261 | diff --git a/lib/lp/code/model/gitref.py b/lib/lp/code/model/gitref.py | |||
1262 | index 61a7526..11a3959 100644 | |||
1263 | --- a/lib/lp/code/model/gitref.py | |||
1264 | +++ b/lib/lp/code/model/gitref.py | |||
1265 | @@ -333,10 +333,10 @@ class GitRefMixin: | |||
1266 | 333 | enable_hosting=None, enable_memcache=None, logger=None): | 333 | enable_hosting=None, enable_memcache=None, logger=None): |
1267 | 334 | if enable_hosting is None: | 334 | if enable_hosting is None: |
1268 | 335 | enable_hosting = not getFeatureFlag( | 335 | enable_hosting = not getFeatureFlag( |
1270 | 336 | u"code.git.log.disable_hosting") | 336 | "code.git.log.disable_hosting") |
1271 | 337 | if enable_memcache is None: | 337 | if enable_memcache is None: |
1272 | 338 | enable_memcache = not getFeatureFlag( | 338 | enable_memcache = not getFeatureFlag( |
1274 | 339 | u"code.git.log.disable_memcache") | 339 | "code.git.log.disable_memcache") |
1275 | 340 | path = self.repository.getInternalPath() | 340 | path = self.repository.getInternalPath() |
1276 | 341 | if (union_repository is not None and | 341 | if (union_repository is not None and |
1277 | 342 | union_repository != self.repository): | 342 | union_repository != self.repository): |
1278 | @@ -636,9 +636,9 @@ class GitRef(GitRefMixin, StormBase): | |||
1279 | 636 | def findByReposAndPaths(cls, repos_and_paths): | 636 | def findByReposAndPaths(cls, repos_and_paths): |
1280 | 637 | """See `IGitRefSet`""" | 637 | """See `IGitRefSet`""" |
1281 | 638 | def full_path(path): | 638 | def full_path(path): |
1283 | 639 | if path.startswith(u"refs/heads/"): | 639 | if path.startswith("refs/heads/"): |
1284 | 640 | return path | 640 | return path |
1286 | 641 | return u"refs/heads/%s" % path | 641 | return "refs/heads/%s" % path |
1287 | 642 | 642 | ||
1288 | 643 | condition = None | 643 | condition = None |
1289 | 644 | for repo, path in repos_and_paths: | 644 | for repo, path in repos_and_paths: |
1290 | @@ -702,7 +702,7 @@ class GitRefDefault(GitRefDatabaseBackedMixin): | |||
1291 | 702 | def __init__(self, repository): | 702 | def __init__(self, repository): |
1292 | 703 | self.repository_id = repository.id | 703 | self.repository_id = repository.id |
1293 | 704 | self.repository = repository | 704 | self.repository = repository |
1295 | 705 | self.path = u"HEAD" | 705 | self.path = "HEAD" |
1296 | 706 | 706 | ||
1297 | 707 | _non_database_attributes = ("repository_id", "repository", "path") | 707 | _non_database_attributes = ("repository_id", "repository", "path") |
1298 | 708 | 708 | ||
1299 | diff --git a/lib/lp/code/model/gitrepository.py b/lib/lp/code/model/gitrepository.py | |||
1300 | index 43a005a..c6b8ada 100644 | |||
1301 | --- a/lib/lp/code/model/gitrepository.py | |||
1302 | +++ b/lib/lp/code/model/gitrepository.py | |||
1303 | @@ -500,7 +500,7 @@ class GitRepository(StormBase, WebhookTargetMixin, AccessTokenTargetMixin, | |||
1304 | 500 | description=None, status=None, loose_object_count=None, | 500 | description=None, status=None, loose_object_count=None, |
1305 | 501 | pack_count=None, date_last_scanned=None, | 501 | pack_count=None, date_last_scanned=None, |
1306 | 502 | date_last_repacked=None): | 502 | date_last_repacked=None): |
1308 | 503 | super(GitRepository, self).__init__() | 503 | super().__init__() |
1309 | 504 | self.repository_type = repository_type | 504 | self.repository_type = repository_type |
1310 | 505 | self.registrant = registrant | 505 | self.registrant = registrant |
1311 | 506 | self.owner = owner | 506 | self.owner = owner |
1312 | @@ -798,7 +798,7 @@ class GitRepository(StormBase, WebhookTargetMixin, AccessTokenTargetMixin, | |||
1313 | 798 | return Store.of(self).find( | 798 | return Store.of(self).find( |
1314 | 799 | GitRef, | 799 | GitRef, |
1315 | 800 | GitRef.repository_id == self.id, | 800 | GitRef.repository_id == self.id, |
1317 | 801 | GitRef.path.startswith(u"refs/heads/")).order_by(GitRef.path) | 801 | GitRef.path.startswith("refs/heads/")).order_by(GitRef.path) |
1318 | 802 | 802 | ||
1319 | 803 | @property | 803 | @property |
1320 | 804 | def branches_by_date(self): | 804 | def branches_by_date(self): |
1321 | @@ -831,11 +831,11 @@ class GitRepository(StormBase, WebhookTargetMixin, AccessTokenTargetMixin, | |||
1322 | 831 | self.getInternalPath(), default_branch=ref.path) | 831 | self.getInternalPath(), default_branch=ref.path) |
1323 | 832 | 832 | ||
1324 | 833 | def getRefByPath(self, path): | 833 | def getRefByPath(self, path): |
1326 | 834 | if path == u"HEAD": | 834 | if path == "HEAD": |
1327 | 835 | return GitRefDefault(self) | 835 | return GitRefDefault(self) |
1328 | 836 | paths = [path] | 836 | paths = [path] |
1331 | 837 | if not path.startswith(u"refs/heads/"): | 837 | if not path.startswith("refs/heads/"): |
1332 | 838 | paths.append(u"refs/heads/%s" % path) | 838 | paths.append("refs/heads/%s" % path) |
1333 | 839 | refs = Store.of(self).find( | 839 | refs = Store.of(self).find( |
1334 | 840 | GitRef, | 840 | GitRef, |
1335 | 841 | GitRef.repository_id == self.id, | 841 | GitRef.repository_id == self.id, |
1336 | @@ -864,8 +864,7 @@ class GitRepository(StormBase, WebhookTargetMixin, AccessTokenTargetMixin, | |||
1337 | 864 | raise ValueError('ref info object does not contain "sha1" key') | 864 | raise ValueError('ref info object does not contain "sha1" key') |
1338 | 865 | if "type" not in obj: | 865 | if "type" not in obj: |
1339 | 866 | raise ValueError('ref info object does not contain "type" key') | 866 | raise ValueError('ref info object does not contain "type" key') |
1342 | 867 | if (not isinstance(obj["sha1"], six.string_types) or | 867 | if not isinstance(obj["sha1"], str) or len(obj["sha1"]) != 40: |
1341 | 868 | len(obj["sha1"]) != 40): | ||
1343 | 869 | raise ValueError('ref info sha1 is not a 40-character string') | 868 | raise ValueError('ref info sha1 is not a 40-character string') |
1344 | 870 | if obj["type"] not in object_type_map: | 869 | if obj["type"] not in object_type_map: |
1345 | 871 | raise ValueError('ref info type is not a recognised object type') | 870 | raise ValueError('ref info type is not a recognised object type') |
1346 | @@ -1971,7 +1970,7 @@ class DeletionCallable(DeletionOperation): | |||
1347 | 1971 | """Deletion operation that invokes a callable.""" | 1970 | """Deletion operation that invokes a callable.""" |
1348 | 1972 | 1971 | ||
1349 | 1973 | def __init__(self, affected_object, rationale, func, *args, **kwargs): | 1972 | def __init__(self, affected_object, rationale, func, *args, **kwargs): |
1351 | 1974 | super(DeletionCallable, self).__init__(affected_object, rationale) | 1973 | super().__init__(affected_object, rationale) |
1352 | 1975 | self.func = func | 1974 | self.func = func |
1353 | 1976 | self.args = args | 1975 | self.args = args |
1354 | 1977 | self.kwargs = kwargs | 1976 | self.kwargs = kwargs |
1355 | @@ -2231,7 +2230,7 @@ class GitRepositoryMacaroonIssuer(MacaroonIssuerBase): | |||
1356 | 2231 | _timestamp_format = "%Y-%m-%dT%H:%M:%S.%f" | 2230 | _timestamp_format = "%Y-%m-%dT%H:%M:%S.%f" |
1357 | 2232 | 2231 | ||
1358 | 2233 | def __init__(self): | 2232 | def __init__(self): |
1360 | 2234 | super(GitRepositoryMacaroonIssuer, self).__init__() | 2233 | super().__init__() |
1361 | 2235 | self.checkers = { | 2234 | self.checkers = { |
1362 | 2236 | "lp.principal.openid-identifier": self.verifyOpenIDIdentifier, | 2235 | "lp.principal.openid-identifier": self.verifyOpenIDIdentifier, |
1363 | 2237 | "lp.expires": self.verifyExpires, | 2236 | "lp.expires": self.verifyExpires, |
1364 | @@ -2260,8 +2259,7 @@ class GitRepositoryMacaroonIssuer(MacaroonIssuerBase): | |||
1365 | 2260 | 2259 | ||
1366 | 2261 | def issueMacaroon(self, context, user=None, **kwargs): | 2260 | def issueMacaroon(self, context, user=None, **kwargs): |
1367 | 2262 | """See `IMacaroonIssuer`.""" | 2261 | """See `IMacaroonIssuer`.""" |
1370 | 2263 | macaroon = super(GitRepositoryMacaroonIssuer, self).issueMacaroon( | 2262 | macaroon = super().issueMacaroon(context, user=user, **kwargs) |
1369 | 2264 | context, user=user, **kwargs) | ||
1371 | 2265 | naked_account = removeSecurityProxy(user).account | 2263 | naked_account = removeSecurityProxy(user).account |
1372 | 2266 | macaroon.add_first_party_caveat( | 2264 | macaroon.add_first_party_caveat( |
1373 | 2267 | "lp.principal.openid-identifier " + | 2265 | "lp.principal.openid-identifier " + |
1374 | diff --git a/lib/lp/code/model/gitrule.py b/lib/lp/code/model/gitrule.py | |||
1375 | index 5d416b7..b16d327 100644 | |||
1376 | --- a/lib/lp/code/model/gitrule.py | |||
1377 | +++ b/lib/lp/code/model/gitrule.py | |||
1378 | @@ -111,7 +111,7 @@ class GitRule(StormBase): | |||
1379 | 111 | 111 | ||
1380 | 112 | def __init__(self, repository, position, ref_pattern, creator, | 112 | def __init__(self, repository, position, ref_pattern, creator, |
1381 | 113 | date_created): | 113 | date_created): |
1383 | 114 | super(GitRule, self).__init__() | 114 | super().__init__() |
1384 | 115 | self.repository = repository | 115 | self.repository = repository |
1385 | 116 | self.position = position | 116 | self.position = position |
1386 | 117 | self.ref_pattern = ref_pattern | 117 | self.ref_pattern = ref_pattern |
1387 | diff --git a/lib/lp/code/model/gitsubscription.py b/lib/lp/code/model/gitsubscription.py | |||
1388 | index 8ad435a..2c61db4 100644 | |||
1389 | --- a/lib/lp/code/model/gitsubscription.py | |||
1390 | +++ b/lib/lp/code/model/gitsubscription.py | |||
1391 | @@ -53,7 +53,7 @@ class GitSubscription(StormBase): | |||
1392 | 53 | 53 | ||
1393 | 54 | def __init__(self, person, repository, notification_level, max_diff_lines, | 54 | def __init__(self, person, repository, notification_level, max_diff_lines, |
1394 | 55 | review_level, subscribed_by): | 55 | review_level, subscribed_by): |
1396 | 56 | super(GitSubscription, self).__init__() | 56 | super().__init__() |
1397 | 57 | self.person = person | 57 | self.person = person |
1398 | 58 | self.repository = repository | 58 | self.repository = repository |
1399 | 59 | self.notification_level = notification_level | 59 | self.notification_level = notification_level |
1400 | diff --git a/lib/lp/code/model/recipebuilder.py b/lib/lp/code/model/recipebuilder.py | |||
1401 | index 46ef5b8..abd82e8 100644 | |||
1402 | --- a/lib/lp/code/model/recipebuilder.py | |||
1403 | +++ b/lib/lp/code/model/recipebuilder.py | |||
1404 | @@ -63,8 +63,7 @@ class RecipeBuildBehaviour(BuildFarmJobBehaviourBase): | |||
1405 | 63 | self.build.distroseries.displayname)) | 63 | self.build.distroseries.displayname)) |
1406 | 64 | 64 | ||
1407 | 65 | # Build extra arguments. | 65 | # Build extra arguments. |
1410 | 66 | args = yield super(RecipeBuildBehaviour, self).extraBuildArgs( | 66 | args = yield super().extraBuildArgs(logger=logger) |
1409 | 67 | logger=logger) | ||
1411 | 68 | args['suite'] = self.build.distroseries.getSuite(self.build.pocket) | 67 | args['suite'] = self.build.distroseries.getSuite(self.build.pocket) |
1412 | 69 | requester = self.build.requester | 68 | requester = self.build.requester |
1413 | 70 | if requester.preferredemail is None: | 69 | if requester.preferredemail is None: |
1414 | diff --git a/lib/lp/code/model/revision.py b/lib/lp/code/model/revision.py | |||
1415 | index 680f3a2..2f04cd3 100644 | |||
1416 | --- a/lib/lp/code/model/revision.py | |||
1417 | +++ b/lib/lp/code/model/revision.py | |||
1418 | @@ -286,7 +286,7 @@ class RevisionSet: | |||
1419 | 286 | parent_id=parent_id) | 286 | parent_id=parent_id) |
1420 | 287 | 287 | ||
1421 | 288 | # Create revision properties. | 288 | # Create revision properties. |
1423 | 289 | for name, value in six.iteritems(properties): | 289 | for name, value in properties.items(): |
1424 | 290 | RevisionProperty(revision=revision, name=name, value=value) | 290 | RevisionProperty(revision=revision, name=name, value=value) |
1425 | 291 | 291 | ||
1426 | 292 | return revision | 292 | return revision |
1427 | @@ -377,7 +377,7 @@ class RevisionSet: | |||
1428 | 377 | for bzr_revision in revisions: | 377 | for bzr_revision in revisions: |
1429 | 378 | db_id = revision_db_id[six.ensure_text(bzr_revision.revision_id)] | 378 | db_id = revision_db_id[six.ensure_text(bzr_revision.revision_id)] |
1430 | 379 | # Property data: revision DB id, name, value. | 379 | # Property data: revision DB id, name, value. |
1432 | 380 | for name, value in six.iteritems(bzr_revision.properties): | 380 | for name, value in bzr_revision.properties.items(): |
1433 | 381 | # pristine-tar properties can be huge, and storing them | 381 | # pristine-tar properties can be huge, and storing them |
1434 | 382 | # in the database provides no value. Exclude them. | 382 | # in the database provides no value. Exclude them. |
1435 | 383 | if name.startswith('deb-pristine-delta'): | 383 | if name.startswith('deb-pristine-delta'): |
1436 | diff --git a/lib/lp/code/model/sourcepackagerecipebuild.py b/lib/lp/code/model/sourcepackagerecipebuild.py | |||
1437 | index f10ed3c..7be41ee 100644 | |||
1438 | --- a/lib/lp/code/model/sourcepackagerecipebuild.py | |||
1439 | +++ b/lib/lp/code/model/sourcepackagerecipebuild.py | |||
1440 | @@ -191,7 +191,7 @@ class SourcePackageRecipeBuild(SpecificBuildFarmJobSourceMixin, | |||
1441 | 191 | archive, pocket, date_created): | 191 | archive, pocket, date_created): |
1442 | 192 | """Construct a SourcePackageRecipeBuild.""" | 192 | """Construct a SourcePackageRecipeBuild.""" |
1443 | 193 | processor = distroseries.nominatedarchindep.processor | 193 | processor = distroseries.nominatedarchindep.processor |
1445 | 194 | super(SourcePackageRecipeBuild, self).__init__() | 194 | super().__init__() |
1446 | 195 | self.build_farm_job = build_farm_job | 195 | self.build_farm_job = build_farm_job |
1447 | 196 | self.distroseries = distroseries | 196 | self.distroseries = distroseries |
1448 | 197 | self.recipe = recipe | 197 | self.recipe = recipe |
1449 | diff --git a/lib/lp/code/model/sourcepackagerecipedata.py b/lib/lp/code/model/sourcepackagerecipedata.py | |||
1450 | index f5d849b..0185f42 100644 | |||
1451 | --- a/lib/lp/code/model/sourcepackagerecipedata.py | |||
1452 | +++ b/lib/lp/code/model/sourcepackagerecipedata.py | |||
1453 | @@ -105,7 +105,7 @@ class _SourcePackageRecipeDataInstruction(Storm): | |||
1454 | 105 | def __init__(self, name, type, comment, line_number, branch_or_repository, | 105 | def __init__(self, name, type, comment, line_number, branch_or_repository, |
1455 | 106 | revspec, directory, recipe_data, parent_instruction, | 106 | revspec, directory, recipe_data, parent_instruction, |
1456 | 107 | source_directory): | 107 | source_directory): |
1458 | 108 | super(_SourcePackageRecipeDataInstruction, self).__init__() | 108 | super().__init__() |
1459 | 109 | self.name = six.ensure_text(name) | 109 | self.name = six.ensure_text(name) |
1460 | 110 | self.type = type | 110 | self.type = type |
1461 | 111 | self.comment = comment | 111 | self.comment = comment |
1462 | @@ -431,13 +431,13 @@ class SourcePackageRecipeData(Storm): | |||
1463 | 431 | else: | 431 | else: |
1464 | 432 | self.deb_version_template = six.ensure_text( | 432 | self.deb_version_template = six.ensure_text( |
1465 | 433 | builder_recipe.deb_version) | 433 | builder_recipe.deb_version) |
1467 | 434 | self.recipe_format = six.text_type(builder_recipe.format) | 434 | self.recipe_format = str(builder_recipe.format) |
1468 | 435 | 435 | ||
1469 | 436 | def __init__(self, recipe, recipe_branch_type, sourcepackage_recipe=None, | 436 | def __init__(self, recipe, recipe_branch_type, sourcepackage_recipe=None, |
1470 | 437 | sourcepackage_recipe_build=None): | 437 | sourcepackage_recipe_build=None): |
1471 | 438 | """Initialize from the bzr-builder recipe and link it to a db recipe. | 438 | """Initialize from the bzr-builder recipe and link it to a db recipe. |
1472 | 439 | """ | 439 | """ |
1474 | 440 | super(SourcePackageRecipeData, self).__init__() | 440 | super().__init__() |
1475 | 441 | self.setRecipe(recipe, recipe_branch_type) | 441 | self.setRecipe(recipe, recipe_branch_type) |
1476 | 442 | self.sourcepackage_recipe = sourcepackage_recipe | 442 | self.sourcepackage_recipe = sourcepackage_recipe |
1477 | 443 | self.sourcepackage_recipe_build = sourcepackage_recipe_build | 443 | self.sourcepackage_recipe_build = sourcepackage_recipe_build |
1478 | diff --git a/lib/lp/code/model/tests/test_branch.py b/lib/lp/code/model/tests/test_branch.py | |||
1479 | index 16858d2..4419b12 100644 | |||
1480 | --- a/lib/lp/code/model/tests/test_branch.py | |||
1481 | +++ b/lib/lp/code/model/tests/test_branch.py | |||
1482 | @@ -188,7 +188,7 @@ class TestCodeImport(TestCase): | |||
1483 | 188 | layer = LaunchpadZopelessLayer | 188 | layer = LaunchpadZopelessLayer |
1484 | 189 | 189 | ||
1485 | 190 | def setUp(self): | 190 | def setUp(self): |
1487 | 191 | super(TestCodeImport, self).setUp() | 191 | super().setUp() |
1488 | 192 | login('test@canonical.com') | 192 | login('test@canonical.com') |
1489 | 193 | self.factory = LaunchpadObjectFactory() | 193 | self.factory = LaunchpadObjectFactory() |
1490 | 194 | 194 | ||
1491 | @@ -1468,7 +1468,7 @@ class TestBranchDeletionConsequences(TestCase): | |||
1492 | 1468 | layer = LaunchpadZopelessLayer | 1468 | layer = LaunchpadZopelessLayer |
1493 | 1469 | 1469 | ||
1494 | 1470 | def setUp(self): | 1470 | def setUp(self): |
1496 | 1471 | super(TestBranchDeletionConsequences, self).setUp() | 1471 | super().setUp() |
1497 | 1472 | login('test@canonical.com') | 1472 | login('test@canonical.com') |
1498 | 1473 | self.factory = LaunchpadObjectFactory() | 1473 | self.factory = LaunchpadObjectFactory() |
1499 | 1474 | # Has to be a product branch because of merge proposals. | 1474 | # Has to be a product branch because of merge proposals. |
1500 | @@ -1823,7 +1823,7 @@ class BranchAddLandingTarget(TestCaseWithFactory): | |||
1501 | 1823 | layer = DatabaseFunctionalLayer | 1823 | layer = DatabaseFunctionalLayer |
1502 | 1824 | 1824 | ||
1503 | 1825 | def setUp(self): | 1825 | def setUp(self): |
1505 | 1826 | super(BranchAddLandingTarget, self).setUp('admin@canonical.com') | 1826 | super().setUp('admin@canonical.com') |
1506 | 1827 | self.product = self.factory.makeProduct() | 1827 | self.product = self.factory.makeProduct() |
1507 | 1828 | 1828 | ||
1508 | 1829 | self.user = self.factory.makePerson() | 1829 | self.user = self.factory.makePerson() |
1509 | @@ -1837,7 +1837,7 @@ class BranchAddLandingTarget(TestCaseWithFactory): | |||
1510 | 1837 | 1837 | ||
1511 | 1838 | def tearDown(self): | 1838 | def tearDown(self): |
1512 | 1839 | logout() | 1839 | logout() |
1514 | 1840 | super(BranchAddLandingTarget, self).tearDown() | 1840 | super().tearDown() |
1515 | 1841 | 1841 | ||
1516 | 1842 | def assertOnePendingReview(self, proposal, reviewer, review_type=None): | 1842 | def assertOnePendingReview(self, proposal, reviewer, review_type=None): |
1517 | 1843 | # There should be one pending vote for the reviewer with the specified | 1843 | # There should be one pending vote for the reviewer with the specified |
1518 | @@ -3099,7 +3099,7 @@ class TestGetMergeProposals(TestCaseWithFactory): | |||
1519 | 3099 | layer = DatabaseFunctionalLayer | 3099 | layer = DatabaseFunctionalLayer |
1520 | 3100 | 3100 | ||
1521 | 3101 | def setUp(self): | 3101 | def setUp(self): |
1523 | 3102 | super(TestGetMergeProposals, self).setUp() | 3102 | super().setUp() |
1524 | 3103 | self.branch_set = BranchSet() | 3103 | self.branch_set = BranchSet() |
1525 | 3104 | 3104 | ||
1526 | 3105 | def test_getMergeProposals_with_no_merged_revno(self): | 3105 | def test_getMergeProposals_with_no_merged_revno(self): |
1527 | @@ -3549,7 +3549,7 @@ class TestWebservice(TestCaseWithFactory): | |||
1528 | 3549 | layer = DatabaseFunctionalLayer | 3549 | layer = DatabaseFunctionalLayer |
1529 | 3550 | 3550 | ||
1530 | 3551 | def setUp(self): | 3551 | def setUp(self): |
1532 | 3552 | super(TestWebservice, self).setUp() | 3552 | super().setUp() |
1533 | 3553 | self.branch_db = self.factory.makeBranch() | 3553 | self.branch_db = self.factory.makeBranch() |
1534 | 3554 | self.branch_url = api_url(self.branch_db) | 3554 | self.branch_url = api_url(self.branch_db) |
1535 | 3555 | self.webservice = webservice_for_person( | 3555 | self.webservice = webservice_for_person( |
1536 | diff --git a/lib/lp/code/model/tests/test_branchcollection.py b/lib/lp/code/model/tests/test_branchcollection.py | |||
1537 | index e66b16b..062a5ab 100644 | |||
1538 | --- a/lib/lp/code/model/tests/test_branchcollection.py | |||
1539 | +++ b/lib/lp/code/model/tests/test_branchcollection.py | |||
1540 | @@ -106,7 +106,7 @@ class TestGenericBranchCollection(TestCaseWithFactory): | |||
1541 | 106 | layer = DatabaseFunctionalLayer | 106 | layer = DatabaseFunctionalLayer |
1542 | 107 | 107 | ||
1543 | 108 | def setUp(self): | 108 | def setUp(self): |
1545 | 109 | super(TestGenericBranchCollection, self).setUp() | 109 | super().setUp() |
1546 | 110 | remove_all_sample_data_branches() | 110 | remove_all_sample_data_branches() |
1547 | 111 | self.store = IStore(Branch) | 111 | self.store = IStore(Branch) |
1548 | 112 | 112 | ||
1549 | diff --git a/lib/lp/code/model/tests/test_branchhosting.py b/lib/lp/code/model/tests/test_branchhosting.py | |||
1550 | index 1e1f874..0190806 100644 | |||
1551 | --- a/lib/lp/code/model/tests/test_branchhosting.py | |||
1552 | +++ b/lib/lp/code/model/tests/test_branchhosting.py | |||
1553 | @@ -12,7 +12,6 @@ import re | |||
1554 | 12 | 12 | ||
1555 | 13 | from lazr.restful.utils import get_current_browser_request | 13 | from lazr.restful.utils import get_current_browser_request |
1556 | 14 | import responses | 14 | import responses |
1557 | 15 | import six | ||
1558 | 16 | from testtools.matchers import MatchesStructure | 15 | from testtools.matchers import MatchesStructure |
1559 | 17 | from zope.component import getUtility | 16 | from zope.component import getUtility |
1560 | 18 | from zope.interface import implementer | 17 | from zope.interface import implementer |
1561 | @@ -47,7 +46,7 @@ class TestBranchHostingClient(TestCase): | |||
1562 | 47 | layer = ZopelessDatabaseLayer | 46 | layer = ZopelessDatabaseLayer |
1563 | 48 | 47 | ||
1564 | 49 | def setUp(self): | 48 | def setUp(self): |
1566 | 50 | super(TestBranchHostingClient, self).setUp() | 49 | super().setUp() |
1567 | 51 | self.client = getUtility(IBranchHostingClient) | 50 | self.client = getUtility(IBranchHostingClient) |
1568 | 52 | self.endpoint = removeSecurityProxy(self.client).endpoint | 51 | self.endpoint = removeSecurityProxy(self.client).endpoint |
1569 | 53 | self.requests = [] | 52 | self.requests = [] |
1570 | @@ -155,14 +154,14 @@ class TestBranchHostingClient(TestCase): | |||
1571 | 155 | "+branch-id/123/+json/files/%2Brev%20id%3F/%2Bfile/%20name%3F") | 154 | "+branch-id/123/+json/files/%2Brev%20id%3F/%2Bfile/%20name%3F") |
1572 | 156 | 155 | ||
1573 | 157 | def test_getBlob(self): | 156 | def test_getBlob(self): |
1575 | 158 | blob = b"".join(six.int2byte(i) for i in range(256)) | 157 | blob = b"".join(bytes((i,)) for i in range(256)) |
1576 | 159 | with self.mockRequests("GET", body=blob): | 158 | with self.mockRequests("GET", body=blob): |
1577 | 160 | response = self.client.getBlob(123, "file-id") | 159 | response = self.client.getBlob(123, "file-id") |
1578 | 161 | self.assertEqual(blob, response) | 160 | self.assertEqual(blob, response) |
1579 | 162 | self.assertRequest("+branch-id/123/download/head%3A/file-id") | 161 | self.assertRequest("+branch-id/123/download/head%3A/file-id") |
1580 | 163 | 162 | ||
1581 | 164 | def test_getBlob_revision(self): | 163 | def test_getBlob_revision(self): |
1583 | 165 | blob = b"".join(six.int2byte(i) for i in range(256)) | 164 | blob = b"".join(bytes((i,)) for i in range(256)) |
1584 | 166 | with self.mockRequests("GET", body=blob): | 165 | with self.mockRequests("GET", body=blob): |
1585 | 167 | response = self.client.getBlob(123, "file-id", rev="a") | 166 | response = self.client.getBlob(123, "file-id", rev="a") |
1586 | 168 | self.assertEqual(blob, response) | 167 | self.assertEqual(blob, response) |
1587 | @@ -195,7 +194,7 @@ class TestBranchHostingClient(TestCase): | |||
1588 | 195 | self.client.getBlob, 123, "file-id") | 194 | self.client.getBlob, 123, "file-id") |
1589 | 196 | 195 | ||
1590 | 197 | def test_getBlob_url_quoting(self): | 196 | def test_getBlob_url_quoting(self): |
1592 | 198 | blob = b"".join(six.int2byte(i) for i in range(256)) | 197 | blob = b"".join(bytes((i,)) for i in range(256)) |
1593 | 199 | with self.mockRequests("GET", body=blob): | 198 | with self.mockRequests("GET", body=blob): |
1594 | 200 | self.client.getBlob(123, "+file/ id?", rev="+rev id?") | 199 | self.client.getBlob(123, "+file/ id?", rev="+rev id?") |
1595 | 201 | self.assertRequest( | 200 | self.assertRequest( |
1596 | @@ -203,12 +202,12 @@ class TestBranchHostingClient(TestCase): | |||
1597 | 203 | 202 | ||
1598 | 204 | def test_works_in_job(self): | 203 | def test_works_in_job(self): |
1599 | 205 | # `BranchHostingClient` is usable from a running job. | 204 | # `BranchHostingClient` is usable from a running job. |
1601 | 206 | blob = b"".join(six.int2byte(i) for i in range(256)) | 205 | blob = b"".join(bytes((i,)) for i in range(256)) |
1602 | 207 | 206 | ||
1603 | 208 | @implementer(IRunnableJob) | 207 | @implementer(IRunnableJob) |
1604 | 209 | class GetBlobJob(BaseRunnableJob): | 208 | class GetBlobJob(BaseRunnableJob): |
1605 | 210 | def __init__(self, testcase): | 209 | def __init__(self, testcase): |
1607 | 211 | super(GetBlobJob, self).__init__() | 210 | super().__init__() |
1608 | 212 | self.job = Job() | 211 | self.job = Job() |
1609 | 213 | self.testcase = testcase | 212 | self.testcase = testcase |
1610 | 214 | 213 | ||
1611 | diff --git a/lib/lp/code/model/tests/test_branchjob.py b/lib/lp/code/model/tests/test_branchjob.py | |||
1612 | index d3b7592..718df70 100644 | |||
1613 | --- a/lib/lp/code/model/tests/test_branchjob.py | |||
1614 | +++ b/lib/lp/code/model/tests/test_branchjob.py | |||
1615 | @@ -917,7 +917,7 @@ class TestRosettaUploadJob(TestCaseWithFactory): | |||
1616 | 917 | layer = LaunchpadZopelessLayer | 917 | layer = LaunchpadZopelessLayer |
1617 | 918 | 918 | ||
1618 | 919 | def setUp(self): | 919 | def setUp(self): |
1620 | 920 | super(TestRosettaUploadJob, self).setUp() | 920 | super().setUp() |
1621 | 921 | self.series = None | 921 | self.series = None |
1622 | 922 | 922 | ||
1623 | 923 | def _makeBranchWithTreeAndFile(self, file_name, file_content=None): | 923 | def _makeBranchWithTreeAndFile(self, file_name, file_content=None): |
1624 | diff --git a/lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py b/lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py | |||
1625 | index 386bb4b..319476f 100644 | |||
1626 | --- a/lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py | |||
1627 | +++ b/lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py | |||
1628 | @@ -37,8 +37,7 @@ class TestGetProductSeriesForBranches(TestCaseWithFactory): | |||
1629 | 37 | def setUp(self): | 37 | def setUp(self): |
1630 | 38 | # Log in as an admin as we are setting series branches, which is a | 38 | # Log in as an admin as we are setting series branches, which is a |
1631 | 39 | # protected activity. | 39 | # protected activity. |
1634 | 40 | super(TestGetProductSeriesForBranches, self).setUp( | 40 | super().setUp('admin@canonical.com') |
1633 | 41 | 'admin@canonical.com') | ||
1635 | 42 | self.product = self.factory.makeProduct() | 41 | self.product = self.factory.makeProduct() |
1636 | 43 | self.branches = [ | 42 | self.branches = [ |
1637 | 44 | self.factory.makeProductBranch(product=self.product) | 43 | self.factory.makeProductBranch(product=self.product) |
1638 | @@ -114,8 +113,7 @@ class TestGetOfficialSourcePackageLinksForBranches(TestCaseWithFactory): | |||
1639 | 114 | def setUp(self): | 113 | def setUp(self): |
1640 | 115 | # Log in an admin as we are setting official branches, which is a | 114 | # Log in an admin as we are setting official branches, which is a |
1641 | 116 | # protected activity. | 115 | # protected activity. |
1644 | 117 | super(TestGetOfficialSourcePackageLinksForBranches, self).setUp( | 116 | super().setUp('admin@canonical.com') |
1643 | 118 | 'admin@canonical.com') | ||
1645 | 119 | 117 | ||
1646 | 120 | def test_with_branches(self): | 118 | def test_with_branches(self): |
1647 | 121 | # Test the selection of the links. | 119 | # Test the selection of the links. |
1648 | diff --git a/lib/lp/code/model/tests/test_branchmergeproposal.py b/lib/lp/code/model/tests/test_branchmergeproposal.py | |||
1649 | index ed4fdd4..fd51edf 100644 | |||
1650 | --- a/lib/lp/code/model/tests/test_branchmergeproposal.py | |||
1651 | +++ b/lib/lp/code/model/tests/test_branchmergeproposal.py | |||
1652 | @@ -1027,7 +1027,7 @@ class TestMergeProposalWebhooks(WithVCSScenarios, TestCaseWithFactory): | |||
1653 | 1027 | layer = DatabaseFunctionalLayer | 1027 | layer = DatabaseFunctionalLayer |
1654 | 1028 | 1028 | ||
1655 | 1029 | def setUp(self): | 1029 | def setUp(self): |
1657 | 1030 | super(TestMergeProposalWebhooks, self).setUp() | 1030 | super().setUp() |
1658 | 1031 | self.useFixture(FeatureFixture( | 1031 | self.useFixture(FeatureFixture( |
1659 | 1032 | {BRANCH_MERGE_PROPOSAL_WEBHOOKS_FEATURE_FLAG: "on"})) | 1032 | {BRANCH_MERGE_PROPOSAL_WEBHOOKS_FEATURE_FLAG: "on"})) |
1660 | 1033 | 1033 | ||
1661 | @@ -1509,7 +1509,7 @@ class TestBranchMergeProposalBugs(WithVCSScenarios, TestCaseWithFactory): | |||
1662 | 1509 | layer = DatabaseFunctionalLayer | 1509 | layer = DatabaseFunctionalLayer |
1663 | 1510 | 1510 | ||
1664 | 1511 | def setUp(self): | 1511 | def setUp(self): |
1666 | 1512 | super(TestBranchMergeProposalBugs, self).setUp() | 1512 | super().setUp() |
1667 | 1513 | self.user = self.factory.makePerson() | 1513 | self.user = self.factory.makePerson() |
1668 | 1514 | login_person(self.user) | 1514 | login_person(self.user) |
1669 | 1515 | if self.git: | 1515 | if self.git: |
1670 | @@ -1690,16 +1690,15 @@ class TestBranchMergeProposalBugs(WithVCSScenarios, TestCaseWithFactory): | |||
1671 | 1690 | bmp.updateRelatedBugsFromSource() | 1690 | bmp.updateRelatedBugsFromSource() |
1672 | 1691 | self.assertEqual([bug], bmp.bugs) | 1691 | self.assertEqual([bug], bmp.bugs) |
1673 | 1692 | matches_expected_xref = MatchesDict( | 1692 | matches_expected_xref = MatchesDict( |
1676 | 1693 | {("bug", six.text_type(bug.id)): | 1693 | {("bug", str(bug.id)): ContainsDict({"metadata": Is(None)})}) |
1675 | 1694 | ContainsDict({"metadata": Is(None)})}) | ||
1677 | 1695 | self.assertThat( | 1694 | self.assertThat( |
1678 | 1696 | getUtility(IXRefSet).findFrom( | 1695 | getUtility(IXRefSet).findFrom( |
1680 | 1697 | ("merge_proposal", six.text_type(bmp.id)), types=["bug"]), | 1696 | ("merge_proposal", str(bmp.id)), types=["bug"]), |
1681 | 1698 | matches_expected_xref) | 1697 | matches_expected_xref) |
1682 | 1699 | self._setUpLog([bug]) | 1698 | self._setUpLog([bug]) |
1683 | 1700 | self.assertThat( | 1699 | self.assertThat( |
1684 | 1701 | getUtility(IXRefSet).findFrom( | 1700 | getUtility(IXRefSet).findFrom( |
1686 | 1702 | ("merge_proposal", six.text_type(bmp.id)), types=["bug"]), | 1701 | ("merge_proposal", str(bmp.id)), types=["bug"]), |
1687 | 1703 | matches_expected_xref) | 1702 | matches_expected_xref) |
1688 | 1704 | 1703 | ||
1689 | 1705 | def test_updateRelatedBugsFromSource_honours_limit(self): | 1704 | def test_updateRelatedBugsFromSource_honours_limit(self): |
1690 | @@ -2252,7 +2251,7 @@ class TestScheduleDiffUpdates(TestCaseWithFactory): | |||
1691 | 2252 | layer = DatabaseFunctionalLayer | 2251 | layer = DatabaseFunctionalLayer |
1692 | 2253 | 2252 | ||
1693 | 2254 | def setUp(self): | 2253 | def setUp(self): |
1695 | 2255 | super(TestScheduleDiffUpdates, self).setUp() | 2254 | super().setUp() |
1696 | 2256 | self.job_source = removeSecurityProxy( | 2255 | self.job_source = removeSecurityProxy( |
1697 | 2257 | getUtility(IBranchMergeProposalJobSource)) | 2256 | getUtility(IBranchMergeProposalJobSource)) |
1698 | 2258 | 2257 | ||
1699 | @@ -2511,7 +2510,7 @@ class TestBranchMergeProposalInlineComments(TestCaseWithFactory): | |||
1700 | 2511 | layer = LaunchpadFunctionalLayer | 2510 | layer = LaunchpadFunctionalLayer |
1701 | 2512 | 2511 | ||
1702 | 2513 | def setUp(self): | 2512 | def setUp(self): |
1704 | 2514 | super(TestBranchMergeProposalInlineComments, self).setUp() | 2513 | super().setUp() |
1705 | 2515 | # Create a testing IPerson, IPreviewDiff and IBranchMergeProposal | 2514 | # Create a testing IPerson, IPreviewDiff and IBranchMergeProposal |
1706 | 2516 | # for tests. Log in as the testing IPerson. | 2515 | # for tests. Log in as the testing IPerson. |
1707 | 2517 | self.person = self.factory.makePerson() | 2516 | self.person = self.factory.makePerson() |
1708 | diff --git a/lib/lp/code/model/tests/test_branchmergeproposaljobs.py b/lib/lp/code/model/tests/test_branchmergeproposaljobs.py | |||
1709 | index 53f293c..44f04fc 100644 | |||
1710 | --- a/lib/lp/code/model/tests/test_branchmergeproposaljobs.py | |||
1711 | +++ b/lib/lp/code/model/tests/test_branchmergeproposaljobs.py | |||
1712 | @@ -197,8 +197,7 @@ class TestMergeProposalNeedsReviewEmailJobBzr( | |||
1713 | 197 | 197 | ||
1714 | 198 | def test_run_sends_email(self): | 198 | def test_run_sends_email(self): |
1715 | 199 | self.useBzrBranches(direct_database=True) | 199 | self.useBzrBranches(direct_database=True) |
1718 | 200 | parent = super(TestMergeProposalNeedsReviewEmailJobBzr, self) | 200 | super().test_run_sends_email() |
1717 | 201 | parent.test_run_sends_email() | ||
1719 | 202 | 201 | ||
1720 | 203 | def test_MergeProposalCreateJob_with_sourcepackage_branch(self): | 202 | def test_MergeProposalCreateJob_with_sourcepackage_branch(self): |
1721 | 204 | """Jobs for merge proposals with sourcepackage branches work.""" | 203 | """Jobs for merge proposals with sourcepackage branches work.""" |
1722 | diff --git a/lib/lp/code/model/tests/test_branchnamespace.py b/lib/lp/code/model/tests/test_branchnamespace.py | |||
1723 | index 1c10d07..d0dad62 100644 | |||
1724 | --- a/lib/lp/code/model/tests/test_branchnamespace.py | |||
1725 | +++ b/lib/lp/code/model/tests/test_branchnamespace.py | |||
1726 | @@ -3,7 +3,6 @@ | |||
1727 | 3 | 3 | ||
1728 | 4 | """Tests for `IBranchNamespace` implementations.""" | 4 | """Tests for `IBranchNamespace` implementations.""" |
1729 | 5 | 5 | ||
1730 | 6 | import six | ||
1731 | 7 | from zope.component import getUtility | 6 | from zope.component import getUtility |
1732 | 8 | from zope.security.proxy import removeSecurityProxy | 7 | from zope.security.proxy import removeSecurityProxy |
1733 | 9 | 8 | ||
1734 | @@ -1106,7 +1105,7 @@ class BaseValidateNewBranchMixin: | |||
1735 | 1106 | def test_permitted_first_character(self): | 1105 | def test_permitted_first_character(self): |
1736 | 1107 | # The first character of a branch name must be a letter or a number. | 1106 | # The first character of a branch name must be a letter or a number. |
1737 | 1108 | namespace = self._getNamespace(self.factory.makePerson()) | 1107 | namespace = self._getNamespace(self.factory.makePerson()) |
1739 | 1109 | for c in [six.unichr(i) for i in range(128)]: | 1108 | for c in [chr(i) for i in range(128)]: |
1740 | 1110 | if c.isalnum(): | 1109 | if c.isalnum(): |
1741 | 1111 | namespace.validateBranchName(c) | 1110 | namespace.validateBranchName(c) |
1742 | 1112 | else: | 1111 | else: |
1743 | @@ -1118,7 +1117,7 @@ class BaseValidateNewBranchMixin: | |||
1744 | 1118 | # After the first character, letters, numbers and certain punctuation | 1117 | # After the first character, letters, numbers and certain punctuation |
1745 | 1119 | # is permitted. | 1118 | # is permitted. |
1746 | 1120 | namespace = self._getNamespace(self.factory.makePerson()) | 1119 | namespace = self._getNamespace(self.factory.makePerson()) |
1748 | 1121 | for c in [six.unichr(i) for i in range(128)]: | 1120 | for c in [chr(i) for i in range(128)]: |
1749 | 1122 | if c.isalnum() or c in '+-_@.': | 1121 | if c.isalnum() or c in '+-_@.': |
1750 | 1123 | namespace.validateBranchName('a' + c) | 1122 | namespace.validateBranchName('a' + c) |
1751 | 1124 | else: | 1123 | else: |
1752 | diff --git a/lib/lp/code/model/tests/test_codeimport.py b/lib/lp/code/model/tests/test_codeimport.py | |||
1753 | index 3af5208..4f9a355 100644 | |||
1754 | --- a/lib/lp/code/model/tests/test_codeimport.py | |||
1755 | +++ b/lib/lp/code/model/tests/test_codeimport.py | |||
1756 | @@ -85,7 +85,7 @@ class TestCodeImportBase(WithScenarios, TestCaseWithFactory): | |||
1757 | 85 | ] | 85 | ] |
1758 | 86 | 86 | ||
1759 | 87 | def setUp(self, *args, **kwargs): | 87 | def setUp(self, *args, **kwargs): |
1761 | 88 | super(TestCodeImportBase, self).setUp(*args, **kwargs) | 88 | super().setUp(*args, **kwargs) |
1762 | 89 | if self.needs_git_hosting_fixture: | 89 | if self.needs_git_hosting_fixture: |
1763 | 90 | self.hosting_fixture = self.useFixture(GitHostingFixture()) | 90 | self.hosting_fixture = self.useFixture(GitHostingFixture()) |
1764 | 91 | 91 | ||
1765 | @@ -372,8 +372,7 @@ class TestCodeImportStatusUpdate(TestCodeImportBase): | |||
1766 | 372 | 372 | ||
1767 | 373 | def setUp(self): | 373 | def setUp(self): |
1768 | 374 | # Log in a VCS Imports member. | 374 | # Log in a VCS Imports member. |
1771 | 375 | super(TestCodeImportStatusUpdate, self).setUp( | 375 | super().setUp('david.allouche@canonical.com') |
1770 | 376 | 'david.allouche@canonical.com') | ||
1772 | 377 | self.import_operator = getUtility(IPersonSet).getByEmail( | 376 | self.import_operator = getUtility(IPersonSet).getByEmail( |
1773 | 378 | 'david.allouche@canonical.com') | 377 | 'david.allouche@canonical.com') |
1774 | 379 | # Remove existing jobs. | 378 | # Remove existing jobs. |
1775 | @@ -505,12 +504,12 @@ class TestCodeImportResultsAttribute(TestCodeImportBase): | |||
1776 | 505 | layer = LaunchpadFunctionalLayer | 504 | layer = LaunchpadFunctionalLayer |
1777 | 506 | 505 | ||
1778 | 507 | def setUp(self): | 506 | def setUp(self): |
1780 | 508 | super(TestCodeImportResultsAttribute, self).setUp() | 507 | super().setUp() |
1781 | 509 | self.code_import = self.factory.makeCodeImport( | 508 | self.code_import = self.factory.makeCodeImport( |
1782 | 510 | target_rcs_type=self.target_rcs_type) | 509 | target_rcs_type=self.target_rcs_type) |
1783 | 511 | 510 | ||
1784 | 512 | def tearDown(self): | 511 | def tearDown(self): |
1786 | 513 | super(TestCodeImportResultsAttribute, self).tearDown() | 512 | super().tearDown() |
1787 | 514 | logout() | 513 | logout() |
1788 | 515 | 514 | ||
1789 | 516 | def test_no_results(self): | 515 | def test_no_results(self): |
1790 | @@ -571,7 +570,7 @@ class TestConsecutiveFailureCount(TestCodeImportBase): | |||
1791 | 571 | layer = LaunchpadZopelessLayer | 570 | layer = LaunchpadZopelessLayer |
1792 | 572 | 571 | ||
1793 | 573 | def setUp(self): | 572 | def setUp(self): |
1795 | 574 | super(TestConsecutiveFailureCount, self).setUp() | 573 | super().setUp() |
1796 | 575 | login('no-priv@canonical.com') | 574 | login('no-priv@canonical.com') |
1797 | 576 | self.machine = self.factory.makeCodeImportMachine() | 575 | self.machine = self.factory.makeCodeImportMachine() |
1798 | 577 | self.machine.setOnline() | 576 | self.machine.setOnline() |
1799 | @@ -713,7 +712,7 @@ class TestTryFailingImportAgain(TestCodeImportBase): | |||
1800 | 713 | 712 | ||
1801 | 714 | def setUp(self): | 713 | def setUp(self): |
1802 | 715 | # Log in a VCS Imports member. | 714 | # Log in a VCS Imports member. |
1804 | 716 | super(TestTryFailingImportAgain, self).setUp() | 715 | super().setUp() |
1805 | 717 | login_person(getUtility(ILaunchpadCelebrities).vcs_imports.teamowner) | 716 | login_person(getUtility(ILaunchpadCelebrities).vcs_imports.teamowner) |
1806 | 718 | 717 | ||
1807 | 719 | def test_mustBeFailing(self): | 718 | def test_mustBeFailing(self): |
1808 | @@ -772,7 +771,7 @@ class TestRequestImport(TestCodeImportBase): | |||
1809 | 772 | 771 | ||
1810 | 773 | def setUp(self): | 772 | def setUp(self): |
1811 | 774 | # We have to be logged in to request imports | 773 | # We have to be logged in to request imports |
1813 | 775 | super(TestRequestImport, self).setUp(user='no-priv@canonical.com') | 774 | super().setUp(user='no-priv@canonical.com') |
1814 | 776 | 775 | ||
1815 | 777 | def test_requestsJob(self): | 776 | def test_requestsJob(self): |
1816 | 778 | code_import = self.factory.makeCodeImport( | 777 | code_import = self.factory.makeCodeImport( |
1817 | diff --git a/lib/lp/code/model/tests/test_codeimportjob.py b/lib/lp/code/model/tests/test_codeimportjob.py | |||
1818 | index d2785a6..72076a2 100644 | |||
1819 | --- a/lib/lp/code/model/tests/test_codeimportjob.py | |||
1820 | +++ b/lib/lp/code/model/tests/test_codeimportjob.py | |||
1821 | @@ -97,7 +97,7 @@ class TestCodeImportJob(TestCaseWithFactory): | |||
1822 | 97 | layer = DatabaseFunctionalLayer | 97 | layer = DatabaseFunctionalLayer |
1823 | 98 | 98 | ||
1824 | 99 | def setUp(self): | 99 | def setUp(self): |
1826 | 100 | super(TestCodeImportJob, self).setUp() | 100 | super().setUp() |
1827 | 101 | login_for_code_imports() | 101 | login_for_code_imports() |
1828 | 102 | 102 | ||
1829 | 103 | def assertArgumentsMatch(self, code_import, matcher, start_job=False): | 103 | def assertArgumentsMatch(self, code_import, matcher, start_job=False): |
1830 | @@ -211,7 +211,7 @@ class TestCodeImportJobSet(TestCaseWithFactory): | |||
1831 | 211 | layer = DatabaseFunctionalLayer | 211 | layer = DatabaseFunctionalLayer |
1832 | 212 | 212 | ||
1833 | 213 | def setUp(self): | 213 | def setUp(self): |
1835 | 214 | super(TestCodeImportJobSet, self).setUp() | 214 | super().setUp() |
1836 | 215 | login_for_code_imports() | 215 | login_for_code_imports() |
1837 | 216 | 216 | ||
1838 | 217 | def test_getByIdExisting(self): | 217 | def test_getByIdExisting(self): |
1839 | @@ -256,7 +256,7 @@ class TestCodeImportJobSetGetJobForMachine(TestCaseWithFactory): | |||
1840 | 256 | def setUp(self): | 256 | def setUp(self): |
1841 | 257 | # Login so we can access the code import system, delete all jobs in | 257 | # Login so we can access the code import system, delete all jobs in |
1842 | 258 | # the sample data and set up some objects. | 258 | # the sample data and set up some objects. |
1844 | 259 | super(TestCodeImportJobSetGetJobForMachine, self).setUp() | 259 | super().setUp() |
1845 | 260 | login_for_code_imports() | 260 | login_for_code_imports() |
1846 | 261 | for job in IStore(CodeImportJob).find(CodeImportJob): | 261 | for job in IStore(CodeImportJob).find(CodeImportJob): |
1847 | 262 | job.destroySelf() | 262 | job.destroySelf() |
1848 | @@ -370,7 +370,7 @@ class ReclaimableJobTests(TestCaseWithFactory): | |||
1849 | 370 | LIMIT = config.codeimportworker.maximum_heartbeat_interval | 370 | LIMIT = config.codeimportworker.maximum_heartbeat_interval |
1850 | 371 | 371 | ||
1851 | 372 | def setUp(self): | 372 | def setUp(self): |
1853 | 373 | super(ReclaimableJobTests, self).setUp() | 373 | super().setUp() |
1854 | 374 | login_for_code_imports() | 374 | login_for_code_imports() |
1855 | 375 | for job in IStore(CodeImportJob).find(CodeImportJob): | 375 | for job in IStore(CodeImportJob).find(CodeImportJob): |
1856 | 376 | job.destroySelf() | 376 | job.destroySelf() |
1857 | @@ -461,7 +461,7 @@ class AssertFailureMixin: | |||
1858 | 461 | self.fail("AssertionError was not raised") | 461 | self.fail("AssertionError was not raised") |
1859 | 462 | 462 | ||
1860 | 463 | 463 | ||
1862 | 464 | class NewEvents(object): | 464 | class NewEvents: |
1863 | 465 | """Help in testing the creation of CodeImportEvent objects. | 465 | """Help in testing the creation of CodeImportEvent objects. |
1864 | 466 | 466 | ||
1865 | 467 | To test that an operation creates CodeImportEvent objects, create an | 467 | To test that an operation creates CodeImportEvent objects, create an |
1866 | @@ -527,7 +527,7 @@ class TestCodeImportJobWorkflowNewJob(TestCaseWithFactory, | |||
1867 | 527 | layer = DatabaseFunctionalLayer | 527 | layer = DatabaseFunctionalLayer |
1868 | 528 | 528 | ||
1869 | 529 | def setUp(self): | 529 | def setUp(self): |
1871 | 530 | super(TestCodeImportJobWorkflowNewJob, self).setUp() | 530 | super().setUp() |
1872 | 531 | login_for_code_imports() | 531 | login_for_code_imports() |
1873 | 532 | 532 | ||
1874 | 533 | def test_wrongReviewStatus(self): | 533 | def test_wrongReviewStatus(self): |
1875 | @@ -631,7 +631,7 @@ class TestCodeImportJobWorkflowDeletePendingJob(TestCaseWithFactory, | |||
1876 | 631 | layer = DatabaseFunctionalLayer | 631 | layer = DatabaseFunctionalLayer |
1877 | 632 | 632 | ||
1878 | 633 | def setUp(self): | 633 | def setUp(self): |
1880 | 634 | super(TestCodeImportJobWorkflowDeletePendingJob, self).setUp() | 634 | super().setUp() |
1881 | 635 | self.import_admin = login_for_code_imports() | 635 | self.import_admin = login_for_code_imports() |
1882 | 636 | 636 | ||
1883 | 637 | def test_wrongReviewStatus(self): | 637 | def test_wrongReviewStatus(self): |
1884 | @@ -687,7 +687,7 @@ class TestCodeImportJobWorkflowRequestJob(TestCaseWithFactory, | |||
1885 | 687 | layer = DatabaseFunctionalLayer | 687 | layer = DatabaseFunctionalLayer |
1886 | 688 | 688 | ||
1887 | 689 | def setUp(self): | 689 | def setUp(self): |
1889 | 690 | super(TestCodeImportJobWorkflowRequestJob, self).setUp() | 690 | super().setUp() |
1890 | 691 | login_for_code_imports() | 691 | login_for_code_imports() |
1891 | 692 | 692 | ||
1892 | 693 | def test_wrongJobState(self): | 693 | def test_wrongJobState(self): |
1893 | @@ -779,7 +779,7 @@ class TestCodeImportJobWorkflowStartJob(TestCaseWithFactory, | |||
1894 | 779 | layer = DatabaseFunctionalLayer | 779 | layer = DatabaseFunctionalLayer |
1895 | 780 | 780 | ||
1896 | 781 | def setUp(self): | 781 | def setUp(self): |
1898 | 782 | super(TestCodeImportJobWorkflowStartJob, self).setUp() | 782 | super().setUp() |
1899 | 783 | login_for_code_imports() | 783 | login_for_code_imports() |
1900 | 784 | 784 | ||
1901 | 785 | def test_wrongJobState(self): | 785 | def test_wrongJobState(self): |
1902 | @@ -832,7 +832,7 @@ class TestCodeImportJobWorkflowUpdateHeartbeat(TestCaseWithFactory, | |||
1903 | 832 | layer = DatabaseFunctionalLayer | 832 | layer = DatabaseFunctionalLayer |
1904 | 833 | 833 | ||
1905 | 834 | def setUp(self): | 834 | def setUp(self): |
1907 | 835 | super(TestCodeImportJobWorkflowUpdateHeartbeat, self).setUp() | 835 | super().setUp() |
1908 | 836 | login_for_code_imports() | 836 | login_for_code_imports() |
1909 | 837 | 837 | ||
1910 | 838 | def test_wrongJobState(self): | 838 | def test_wrongJobState(self): |
1911 | @@ -867,7 +867,7 @@ class TestCodeImportJobWorkflowFinishJob(TestCaseWithFactory, | |||
1912 | 867 | layer = LaunchpadFunctionalLayer | 867 | layer = LaunchpadFunctionalLayer |
1913 | 868 | 868 | ||
1914 | 869 | def setUp(self): | 869 | def setUp(self): |
1916 | 870 | super(TestCodeImportJobWorkflowFinishJob, self).setUp() | 870 | super().setUp() |
1917 | 871 | self.vcs_imports = login_for_code_imports() | 871 | self.vcs_imports = login_for_code_imports() |
1918 | 872 | self.machine = self.factory.makeCodeImportMachine(set_online=True) | 872 | self.machine = self.factory.makeCodeImportMachine(set_online=True) |
1919 | 873 | 873 | ||
1920 | @@ -1165,7 +1165,7 @@ class TestCodeImportJobWorkflowReclaimJob(TestCaseWithFactory, | |||
1921 | 1165 | layer = DatabaseFunctionalLayer | 1165 | layer = DatabaseFunctionalLayer |
1922 | 1166 | 1166 | ||
1923 | 1167 | def setUp(self): | 1167 | def setUp(self): |
1925 | 1168 | super(TestCodeImportJobWorkflowReclaimJob, self).setUp() | 1168 | super().setUp() |
1926 | 1169 | login_for_code_imports() | 1169 | login_for_code_imports() |
1927 | 1170 | self.machine = self.factory.makeCodeImportMachine(set_online=True) | 1170 | self.machine = self.factory.makeCodeImportMachine(set_online=True) |
1928 | 1171 | 1171 | ||
1929 | @@ -1300,7 +1300,7 @@ class TestCodeImportJobMacaroonIssuer(MacaroonTestMixin, TestCaseWithFactory): | |||
1930 | 1300 | layer = DatabaseFunctionalLayer | 1300 | layer = DatabaseFunctionalLayer |
1931 | 1301 | 1301 | ||
1932 | 1302 | def setUp(self): | 1302 | def setUp(self): |
1934 | 1303 | super(TestCodeImportJobMacaroonIssuer, self).setUp() | 1303 | super().setUp() |
1935 | 1304 | login_for_code_imports() | 1304 | login_for_code_imports() |
1936 | 1305 | self.pushConfig( | 1305 | self.pushConfig( |
1937 | 1306 | "launchpad", internal_macaroon_secret_key="some-secret") | 1306 | "launchpad", internal_macaroon_secret_key="some-secret") |
1938 | diff --git a/lib/lp/code/model/tests/test_codeimportmachine.py b/lib/lp/code/model/tests/test_codeimportmachine.py | |||
1939 | index 1070610..70fcea3 100644 | |||
1940 | --- a/lib/lp/code/model/tests/test_codeimportmachine.py | |||
1941 | +++ b/lib/lp/code/model/tests/test_codeimportmachine.py | |||
1942 | @@ -23,8 +23,7 @@ class TestCodeImportMachineShouldLookForJob(TestCaseWithFactory): | |||
1943 | 23 | layer = DatabaseFunctionalLayer | 23 | layer = DatabaseFunctionalLayer |
1944 | 24 | 24 | ||
1945 | 25 | def setUp(self): | 25 | def setUp(self): |
1948 | 26 | super(TestCodeImportMachineShouldLookForJob, self).setUp( | 26 | super().setUp('admin@canonical.com') |
1947 | 27 | 'admin@canonical.com') | ||
1949 | 28 | self.machine = self.factory.makeCodeImportMachine(set_online=True) | 27 | self.machine = self.factory.makeCodeImportMachine(set_online=True) |
1950 | 29 | 28 | ||
1951 | 30 | def createJobRunningOnMachine(self, machine): | 29 | def createJobRunningOnMachine(self, machine): |
1952 | diff --git a/lib/lp/code/model/tests/test_codereviewkarma.py b/lib/lp/code/model/tests/test_codereviewkarma.py | |||
1953 | index 5b3027b..846d05d 100644 | |||
1954 | --- a/lib/lp/code/model/tests/test_codereviewkarma.py | |||
1955 | +++ b/lib/lp/code/model/tests/test_codereviewkarma.py | |||
1956 | @@ -27,7 +27,7 @@ class TestCodeReviewKarma(TestCaseWithFactory): | |||
1957 | 27 | def setUp(self): | 27 | def setUp(self): |
1958 | 28 | # Use an admin to get launchpad.Edit on all the branches to easily | 28 | # Use an admin to get launchpad.Edit on all the branches to easily |
1959 | 29 | # approve and reject the proposals. | 29 | # approve and reject the proposals. |
1961 | 30 | super(TestCodeReviewKarma, self).setUp('admin@canonical.com') | 30 | super().setUp('admin@canonical.com') |
1962 | 31 | self.useFixture(ZopeEventHandlerFixture( | 31 | self.useFixture(ZopeEventHandlerFixture( |
1963 | 32 | self._on_karma_assigned, (IPerson, IKarmaAssignedEvent))) | 32 | self._on_karma_assigned, (IPerson, IKarmaAssignedEvent))) |
1964 | 33 | self.karma_events = [] | 33 | self.karma_events = [] |
1965 | diff --git a/lib/lp/code/model/tests/test_gitcollection.py b/lib/lp/code/model/tests/test_gitcollection.py | |||
1966 | index b3250f7..f9fdbe8 100644 | |||
1967 | --- a/lib/lp/code/model/tests/test_gitcollection.py | |||
1968 | +++ b/lib/lp/code/model/tests/test_gitcollection.py | |||
1969 | @@ -120,7 +120,7 @@ class TestGenericGitCollection(TestCaseWithFactory): | |||
1970 | 120 | layer = DatabaseFunctionalLayer | 120 | layer = DatabaseFunctionalLayer |
1971 | 121 | 121 | ||
1972 | 122 | def setUp(self): | 122 | def setUp(self): |
1974 | 123 | super(TestGenericGitCollection, self).setUp() | 123 | super().setUp() |
1975 | 124 | self.store = IStore(GitRepository) | 124 | self.store = IStore(GitRepository) |
1976 | 125 | 125 | ||
1977 | 126 | def test_provides_gitcollection(self): | 126 | def test_provides_gitcollection(self): |
1978 | diff --git a/lib/lp/code/model/tests/test_githosting.py b/lib/lp/code/model/tests/test_githosting.py | |||
1979 | index 3ca4fdc..aa3c671 100644 | |||
1980 | --- a/lib/lp/code/model/tests/test_githosting.py | |||
1981 | +++ b/lib/lp/code/model/tests/test_githosting.py | |||
1982 | @@ -14,7 +14,6 @@ import re | |||
1983 | 14 | 14 | ||
1984 | 15 | from lazr.restful.utils import get_current_browser_request | 15 | from lazr.restful.utils import get_current_browser_request |
1985 | 16 | import responses | 16 | import responses |
1986 | 17 | import six | ||
1987 | 18 | from six.moves.urllib.parse import ( | 17 | from six.moves.urllib.parse import ( |
1988 | 19 | parse_qsl, | 18 | parse_qsl, |
1989 | 20 | urlsplit, | 19 | urlsplit, |
1990 | @@ -69,7 +68,7 @@ class MatchesURL(AfterPreprocessing): | |||
1991 | 69 | lambda qs: sorted(parse_qsl(qs)), | 68 | lambda qs: sorted(parse_qsl(qs)), |
1992 | 70 | MatchesListwise( | 69 | MatchesListwise( |
1993 | 71 | [Equals(pair) for pair in sorted(parse_qsl(split_url.query))])) | 70 | [Equals(pair) for pair in sorted(parse_qsl(split_url.query))])) |
1995 | 72 | super(MatchesURL, self).__init__( | 71 | super().__init__( |
1996 | 73 | urlsplit, MatchesStructure( | 72 | urlsplit, MatchesStructure( |
1997 | 74 | scheme=Equals(split_url.scheme), | 73 | scheme=Equals(split_url.scheme), |
1998 | 75 | netloc=Equals(split_url.netloc), | 74 | netloc=Equals(split_url.netloc), |
1999 | @@ -83,7 +82,7 @@ class TestGitHostingClient(TestCase): | |||
2000 | 83 | layer = ZopelessDatabaseLayer | 82 | layer = ZopelessDatabaseLayer |
2001 | 84 | 83 | ||
2002 | 85 | def setUp(self): | 84 | def setUp(self): |
2004 | 86 | super(TestGitHostingClient, self).setUp() | 85 | super().setUp() |
2005 | 87 | self.client = getUtility(IGitHostingClient) | 86 | self.client = getUtility(IGitHostingClient) |
2006 | 88 | self.endpoint = removeSecurityProxy(self.client).endpoint | 87 | self.endpoint = removeSecurityProxy(self.client).endpoint |
2007 | 89 | self.requests = [] | 88 | self.requests = [] |
2008 | @@ -331,7 +330,7 @@ class TestGitHostingClient(TestCase): | |||
2009 | 331 | self.client.delete, "123") | 330 | self.client.delete, "123") |
2010 | 332 | 331 | ||
2011 | 333 | def test_getBlob(self): | 332 | def test_getBlob(self): |
2013 | 334 | blob = b''.join(six.int2byte(i) for i in range(256)) | 333 | blob = b''.join(bytes((i,)) for i in range(256)) |
2014 | 335 | payload = { | 334 | payload = { |
2015 | 336 | "data": base64.b64encode(blob).decode("UTF-8"), | 335 | "data": base64.b64encode(blob).decode("UTF-8"), |
2016 | 337 | "size": len(blob), | 336 | "size": len(blob), |
2017 | @@ -343,7 +342,7 @@ class TestGitHostingClient(TestCase): | |||
2018 | 343 | "repo/123/blob/dir/path/file/name", method="GET") | 342 | "repo/123/blob/dir/path/file/name", method="GET") |
2019 | 344 | 343 | ||
2020 | 345 | def test_getBlob_revision(self): | 344 | def test_getBlob_revision(self): |
2022 | 346 | blob = b''.join(six.int2byte(i) for i in range(256)) | 345 | blob = b''.join(bytes((i,)) for i in range(256)) |
2023 | 347 | payload = { | 346 | payload = { |
2024 | 348 | "data": base64.b64encode(blob).decode("UTF-8"), | 347 | "data": base64.b64encode(blob).decode("UTF-8"), |
2025 | 349 | "size": len(blob), | 348 | "size": len(blob), |
2026 | @@ -378,7 +377,7 @@ class TestGitHostingClient(TestCase): | |||
2027 | 378 | self.client.getBlob, "123", "dir/path/file/name") | 377 | self.client.getBlob, "123", "dir/path/file/name") |
2028 | 379 | 378 | ||
2029 | 380 | def test_getBlob_url_quoting(self): | 379 | def test_getBlob_url_quoting(self): |
2031 | 381 | blob = b''.join(six.int2byte(i) for i in range(256)) | 380 | blob = b''.join(bytes((i,)) for i in range(256)) |
2032 | 382 | payload = { | 381 | payload = { |
2033 | 383 | "data": base64.b64encode(blob).decode("UTF-8"), | 382 | "data": base64.b64encode(blob).decode("UTF-8"), |
2034 | 384 | "size": len(blob), | 383 | "size": len(blob), |
2035 | @@ -411,7 +410,7 @@ class TestGitHostingClient(TestCase): | |||
2036 | 411 | self.client.getBlob, "123", "dir/path/file/name") | 410 | self.client.getBlob, "123", "dir/path/file/name") |
2037 | 412 | 411 | ||
2038 | 413 | def test_getBlob_wrong_size(self): | 412 | def test_getBlob_wrong_size(self): |
2040 | 414 | blob = b''.join(six.int2byte(i) for i in range(256)) | 413 | blob = b''.join(bytes((i,)) for i in range(256)) |
2041 | 415 | payload = {"data": base64.b64encode(blob).decode("UTF-8"), "size": 0} | 414 | payload = {"data": base64.b64encode(blob).decode("UTF-8"), "size": 0} |
2042 | 416 | with self.mockRequests("GET", json=payload): | 415 | with self.mockRequests("GET", json=payload): |
2043 | 417 | self.assertRaisesWithContent( | 416 | self.assertRaisesWithContent( |
2044 | @@ -465,7 +464,7 @@ class TestGitHostingClient(TestCase): | |||
2045 | 465 | @implementer(IRunnableJob) | 464 | @implementer(IRunnableJob) |
2046 | 466 | class GetRefsJob(BaseRunnableJob): | 465 | class GetRefsJob(BaseRunnableJob): |
2047 | 467 | def __init__(self, testcase): | 466 | def __init__(self, testcase): |
2049 | 468 | super(GetRefsJob, self).__init__() | 467 | super().__init__() |
2050 | 469 | self.job = Job() | 468 | self.job = Job() |
2051 | 470 | self.testcase = testcase | 469 | self.testcase = testcase |
2052 | 471 | 470 | ||
2053 | diff --git a/lib/lp/code/model/tests/test_gitlookup.py b/lib/lp/code/model/tests/test_gitlookup.py | |||
2054 | index 0f8b8fe..8914d4c 100644 | |||
2055 | --- a/lib/lp/code/model/tests/test_gitlookup.py | |||
2056 | +++ b/lib/lp/code/model/tests/test_gitlookup.py | |||
2057 | @@ -38,7 +38,7 @@ class TestGetByHostingPath(TestCaseWithFactory): | |||
2058 | 38 | layer = DatabaseFunctionalLayer | 38 | layer = DatabaseFunctionalLayer |
2059 | 39 | 39 | ||
2060 | 40 | def setUp(self): | 40 | def setUp(self): |
2062 | 41 | super(TestGetByHostingPath, self).setUp() | 41 | super().setUp() |
2063 | 42 | self.lookup = getUtility(IGitLookup) | 42 | self.lookup = getUtility(IGitLookup) |
2064 | 43 | 43 | ||
2065 | 44 | def test_exists(self): | 44 | def test_exists(self): |
2066 | @@ -57,7 +57,7 @@ class TestGetByUniqueName(TestCaseWithFactory): | |||
2067 | 57 | layer = DatabaseFunctionalLayer | 57 | layer = DatabaseFunctionalLayer |
2068 | 58 | 58 | ||
2069 | 59 | def setUp(self): | 59 | def setUp(self): |
2071 | 60 | super(TestGetByUniqueName, self).setUp() | 60 | super().setUp() |
2072 | 61 | self.lookup = getUtility(IGitLookup) | 61 | self.lookup = getUtility(IGitLookup) |
2073 | 62 | 62 | ||
2074 | 63 | def test_not_found(self): | 63 | def test_not_found(self): |
2075 | @@ -121,7 +121,7 @@ class TestGetByPath(TestCaseWithFactory): | |||
2076 | 121 | layer = DatabaseFunctionalLayer | 121 | layer = DatabaseFunctionalLayer |
2077 | 122 | 122 | ||
2078 | 123 | def setUp(self): | 123 | def setUp(self): |
2080 | 124 | super(TestGetByPath, self).setUp() | 124 | super().setUp() |
2081 | 125 | self.lookup = getUtility(IGitLookup) | 125 | self.lookup = getUtility(IGitLookup) |
2082 | 126 | 126 | ||
2083 | 127 | def test_project(self): | 127 | def test_project(self): |
2084 | @@ -213,7 +213,7 @@ class TestGetByUrl(TestCaseWithFactory): | |||
2085 | 213 | layer = DatabaseFunctionalLayer | 213 | layer = DatabaseFunctionalLayer |
2086 | 214 | 214 | ||
2087 | 215 | def setUp(self): | 215 | def setUp(self): |
2089 | 216 | super(TestGetByUrl, self).setUp() | 216 | super().setUp() |
2090 | 217 | self.lookup = getUtility(IGitLookup) | 217 | self.lookup = getUtility(IGitLookup) |
2091 | 218 | 218 | ||
2092 | 219 | def makeProjectRepository(self): | 219 | def makeProjectRepository(self): |
2093 | @@ -309,7 +309,7 @@ class TestGitTraverser(TestCaseWithFactory): | |||
2094 | 309 | layer = DatabaseFunctionalLayer | 309 | layer = DatabaseFunctionalLayer |
2095 | 310 | 310 | ||
2096 | 311 | def setUp(self): | 311 | def setUp(self): |
2098 | 312 | super(TestGitTraverser, self).setUp() | 312 | super().setUp() |
2099 | 313 | self.traverser = getUtility(IGitTraverser) | 313 | self.traverser = getUtility(IGitTraverser) |
2100 | 314 | 314 | ||
2101 | 315 | def assertTraverses(self, path, owner, target, repository=None): | 315 | def assertTraverses(self, path, owner, target, repository=None): |
2102 | diff --git a/lib/lp/code/model/tests/test_gitnamespace.py b/lib/lp/code/model/tests/test_gitnamespace.py | |||
2103 | index 3c4ac13..eb11aa9 100644 | |||
2104 | --- a/lib/lp/code/model/tests/test_gitnamespace.py | |||
2105 | +++ b/lib/lp/code/model/tests/test_gitnamespace.py | |||
2106 | @@ -5,7 +5,6 @@ | |||
2107 | 5 | 5 | ||
2108 | 6 | from unittest import mock | 6 | from unittest import mock |
2109 | 7 | 7 | ||
2110 | 8 | import six | ||
2111 | 9 | from zope.component import getUtility | 8 | from zope.component import getUtility |
2112 | 10 | from zope.security.proxy import removeSecurityProxy | 9 | from zope.security.proxy import removeSecurityProxy |
2113 | 11 | 10 | ||
2114 | @@ -954,8 +953,7 @@ class TestProjectGitNamespaceCanCreateBranches( | |||
2115 | 954 | 953 | ||
2116 | 955 | def setUp(self): | 954 | def setUp(self): |
2117 | 956 | # Setting visibility policies is an admin-only task. | 955 | # Setting visibility policies is an admin-only task. |
2120 | 957 | super(TestProjectGitNamespaceCanCreateBranches, self).setUp( | 956 | super().setUp("admin@canonical.com") |
2119 | 958 | "admin@canonical.com") | ||
2121 | 959 | 957 | ||
2122 | 960 | def test_any_person(self): | 958 | def test_any_person(self): |
2123 | 961 | # If there is no privacy set up, any person can create a personal | 959 | # If there is no privacy set up, any person can create a personal |
2124 | @@ -1117,7 +1115,7 @@ class BaseValidateNewRepositoryMixin: | |||
2125 | 1117 | # The first character of a repository name must be a letter or a | 1115 | # The first character of a repository name must be a letter or a |
2126 | 1118 | # number. | 1116 | # number. |
2127 | 1119 | namespace = self._getNamespace(self.factory.makePerson()) | 1117 | namespace = self._getNamespace(self.factory.makePerson()) |
2129 | 1120 | for c in [six.unichr(i) for i in range(128)]: | 1118 | for c in [chr(i) for i in range(128)]: |
2130 | 1121 | if c.isalnum(): | 1119 | if c.isalnum(): |
2131 | 1122 | namespace.validateRepositoryName(c) | 1120 | namespace.validateRepositoryName(c) |
2132 | 1123 | else: | 1121 | else: |
2133 | @@ -1129,7 +1127,7 @@ class BaseValidateNewRepositoryMixin: | |||
2134 | 1129 | # After the first character, letters, numbers and certain | 1127 | # After the first character, letters, numbers and certain |
2135 | 1130 | # punctuation is permitted. | 1128 | # punctuation is permitted. |
2136 | 1131 | namespace = self._getNamespace(self.factory.makePerson()) | 1129 | namespace = self._getNamespace(self.factory.makePerson()) |
2138 | 1132 | for c in [six.unichr(i) for i in range(128)]: | 1130 | for c in [chr(i) for i in range(128)]: |
2139 | 1133 | if c.isalnum() or c in "+-_@.": | 1131 | if c.isalnum() or c in "+-_@.": |
2140 | 1134 | namespace.validateRepositoryName("a" + c) | 1132 | namespace.validateRepositoryName("a" + c) |
2141 | 1135 | else: | 1133 | else: |
2142 | diff --git a/lib/lp/code/model/tests/test_gitref.py b/lib/lp/code/model/tests/test_gitref.py | |||
2143 | index b97e345..f18287a 100644 | |||
2144 | --- a/lib/lp/code/model/tests/test_gitref.py | |||
2145 | +++ b/lib/lp/code/model/tests/test_gitref.py | |||
2146 | @@ -159,7 +159,7 @@ class TestGitRefGetCommits(TestCaseWithFactory): | |||
2147 | 159 | layer = LaunchpadFunctionalLayer | 159 | layer = LaunchpadFunctionalLayer |
2148 | 160 | 160 | ||
2149 | 161 | def setUp(self): | 161 | def setUp(self): |
2151 | 162 | super(TestGitRefGetCommits, self).setUp() | 162 | super().setUp() |
2152 | 163 | [self.ref] = self.factory.makeGitRefs() | 163 | [self.ref] = self.factory.makeGitRefs() |
2153 | 164 | self.authors = [self.factory.makePerson() for _ in range(2)] | 164 | self.authors = [self.factory.makePerson() for _ in range(2)] |
2154 | 165 | with admin_logged_in(): | 165 | with admin_logged_in(): |
2155 | @@ -492,7 +492,7 @@ class TestGitRefCreateMergeProposal(TestCaseWithFactory): | |||
2156 | 492 | layer = DatabaseFunctionalLayer | 492 | layer = DatabaseFunctionalLayer |
2157 | 493 | 493 | ||
2158 | 494 | def setUp(self): | 494 | def setUp(self): |
2160 | 495 | super(TestGitRefCreateMergeProposal, self).setUp() | 495 | super().setUp() |
2161 | 496 | with admin_logged_in(): | 496 | with admin_logged_in(): |
2162 | 497 | self.project = self.factory.makeProduct() | 497 | self.project = self.factory.makeProduct() |
2163 | 498 | self.user = self.factory.makePerson() | 498 | self.user = self.factory.makePerson() |
2164 | diff --git a/lib/lp/code/model/tests/test_gitrepository.py b/lib/lp/code/model/tests/test_gitrepository.py | |||
2165 | index 6a759be..6155836 100644 | |||
2166 | --- a/lib/lp/code/model/tests/test_gitrepository.py | |||
2167 | +++ b/lib/lp/code/model/tests/test_gitrepository.py | |||
2168 | @@ -601,7 +601,7 @@ class TestGitIdentityMixin(TestCaseWithFactory): | |||
2169 | 601 | layer = DatabaseFunctionalLayer | 601 | layer = DatabaseFunctionalLayer |
2170 | 602 | 602 | ||
2171 | 603 | def setUp(self): | 603 | def setUp(self): |
2173 | 604 | super(TestGitIdentityMixin, self).setUp() | 604 | super().setUp() |
2174 | 605 | self.repository_set = getUtility(IGitRepositorySet) | 605 | self.repository_set = getUtility(IGitRepositorySet) |
2175 | 606 | 606 | ||
2176 | 607 | def assertGitIdentity(self, repository, identity_path): | 607 | def assertGitIdentity(self, repository, identity_path): |
2177 | @@ -792,7 +792,7 @@ class TestGitRepositoryDeletion(TestCaseWithFactory): | |||
2178 | 792 | layer = LaunchpadFunctionalLayer | 792 | layer = LaunchpadFunctionalLayer |
2179 | 793 | 793 | ||
2180 | 794 | def setUp(self): | 794 | def setUp(self): |
2182 | 795 | super(TestGitRepositoryDeletion, self).setUp() | 795 | super().setUp() |
2183 | 796 | self.user = self.factory.makePerson() | 796 | self.user = self.factory.makePerson() |
2184 | 797 | self.project = self.factory.makeProduct(owner=self.user) | 797 | self.project = self.factory.makeProduct(owner=self.user) |
2185 | 798 | self.repository = self.factory.makeGitRepository( | 798 | self.repository = self.factory.makeGitRepository( |
2186 | @@ -1001,8 +1001,7 @@ class TestGitRepositoryDeletionConsequences(TestCaseWithFactory): | |||
2187 | 1001 | layer = ZopelessDatabaseLayer | 1001 | layer = ZopelessDatabaseLayer |
2188 | 1002 | 1002 | ||
2189 | 1003 | def setUp(self): | 1003 | def setUp(self): |
2192 | 1004 | super(TestGitRepositoryDeletionConsequences, self).setUp( | 1004 | super().setUp(user="test@canonical.com") |
2191 | 1005 | user="test@canonical.com") | ||
2193 | 1006 | self.repository = self.factory.makeGitRepository() | 1005 | self.repository = self.factory.makeGitRepository() |
2194 | 1007 | [self.ref] = self.factory.makeGitRefs(repository=self.repository) | 1006 | [self.ref] = self.factory.makeGitRefs(repository=self.repository) |
2195 | 1008 | # The owner of the repository is subscribed to the repository when | 1007 | # The owner of the repository is subscribed to the repository when |
2196 | @@ -1537,7 +1536,7 @@ class TestGitRepositoryPrivacy(TestCaseWithFactory): | |||
2197 | 1537 | 1536 | ||
2198 | 1538 | def setUp(self): | 1537 | def setUp(self): |
2199 | 1539 | # Use an admin user as we aren't checking edit permissions here. | 1538 | # Use an admin user as we aren't checking edit permissions here. |
2201 | 1540 | super(TestGitRepositoryPrivacy, self).setUp("admin@canonical.com") | 1539 | super().setUp("admin@canonical.com") |
2202 | 1541 | 1540 | ||
2203 | 1542 | def test_personal_repositories_for_private_teams_are_private(self): | 1541 | def test_personal_repositories_for_private_teams_are_private(self): |
2204 | 1543 | team = self.factory.makeTeam( | 1542 | team = self.factory.makeTeam( |
2205 | @@ -2865,7 +2864,7 @@ class TestGitRepositoryFork(TestCaseWithFactory): | |||
2206 | 2865 | layer = DatabaseFunctionalLayer | 2864 | layer = DatabaseFunctionalLayer |
2207 | 2866 | 2865 | ||
2208 | 2867 | def setUp(self): | 2866 | def setUp(self): |
2210 | 2868 | super(TestGitRepositoryFork, self).setUp() | 2867 | super().setUp() |
2211 | 2869 | self.hosting_fixture = self.useFixture(GitHostingFixture()) | 2868 | self.hosting_fixture = self.useFixture(GitHostingFixture()) |
2212 | 2870 | 2869 | ||
2213 | 2871 | def test_fork(self): | 2870 | def test_fork(self): |
2214 | @@ -3474,7 +3473,7 @@ class TestGitRepositorySet(TestCaseWithFactory): | |||
2215 | 3474 | layer = DatabaseFunctionalLayer | 3473 | layer = DatabaseFunctionalLayer |
2216 | 3475 | 3474 | ||
2217 | 3476 | def setUp(self): | 3475 | def setUp(self): |
2219 | 3477 | super(TestGitRepositorySet, self).setUp() | 3476 | super().setUp() |
2220 | 3478 | self.repository_set = getUtility(IGitRepositorySet) | 3477 | self.repository_set = getUtility(IGitRepositorySet) |
2221 | 3479 | 3478 | ||
2222 | 3480 | def test_new(self): | 3479 | def test_new(self): |
2223 | @@ -3775,7 +3774,7 @@ class TestGitRepositorySetDefaultsMixin: | |||
2224 | 3775 | layer = DatabaseFunctionalLayer | 3774 | layer = DatabaseFunctionalLayer |
2225 | 3776 | 3775 | ||
2226 | 3777 | def setUp(self): | 3776 | def setUp(self): |
2228 | 3778 | super(TestGitRepositorySetDefaultsMixin, self).setUp() | 3777 | super().setUp() |
2229 | 3779 | self.repository_set = getUtility(IGitRepositorySet) | 3778 | self.repository_set = getUtility(IGitRepositorySet) |
2230 | 3780 | self.get_method = self.repository_set.getDefaultRepository | 3779 | self.get_method = self.repository_set.getDefaultRepository |
2231 | 3781 | self.set_method = (lambda target, repository, user: | 3780 | self.set_method = (lambda target, repository, user: |
2232 | @@ -3857,7 +3856,7 @@ class TestGitRepositorySetDefaultsOwnerMixin( | |||
2233 | 3857 | TestGitRepositorySetDefaultsMixin): | 3856 | TestGitRepositorySetDefaultsMixin): |
2234 | 3858 | 3857 | ||
2235 | 3859 | def setUp(self): | 3858 | def setUp(self): |
2237 | 3860 | super(TestGitRepositorySetDefaultsOwnerMixin, self).setUp() | 3859 | super().setUp() |
2238 | 3861 | self.person = self.factory.makePerson() | 3860 | self.person = self.factory.makePerson() |
2239 | 3862 | self.get_method = partial( | 3861 | self.get_method = partial( |
2240 | 3863 | self.repository_set.getDefaultRepositoryForOwner, self.person) | 3862 | self.repository_set.getDefaultRepositoryForOwner, self.person) |
2241 | @@ -4098,7 +4097,7 @@ class TestGitRepositoryWebservice(TestCaseWithFactory): | |||
2242 | 4098 | self.assertNewWorks(self.factory.makePerson()) | 4097 | self.assertNewWorks(self.factory.makePerson()) |
2243 | 4099 | 4098 | ||
2244 | 4100 | def test_new_repo_not_owner(self): | 4099 | def test_new_repo_not_owner(self): |
2246 | 4101 | non_ascii_name = u'AndrĆ© LuĆs Lopes' | 4100 | non_ascii_name = 'AndrĆ© LuĆs Lopes' |
2247 | 4102 | other_user = self.factory.makePerson(displayname=non_ascii_name) | 4101 | other_user = self.factory.makePerson(displayname=non_ascii_name) |
2248 | 4103 | owner_url = api_url(other_user) | 4102 | owner_url = api_url(other_user) |
2249 | 4104 | webservice_user = self.factory.makePerson() | 4103 | webservice_user = self.factory.makePerson() |
2250 | @@ -4109,8 +4108,8 @@ class TestGitRepositoryWebservice(TestCaseWithFactory): | |||
2251 | 4109 | response = webservice.named_post( | 4108 | response = webservice.named_post( |
2252 | 4110 | "/+git", "new", owner=owner_url, target=owner_url, name=name) | 4109 | "/+git", "new", owner=owner_url, target=owner_url, name=name) |
2253 | 4111 | self.assertEqual(400, response.status) | 4110 | self.assertEqual(400, response.status) |
2256 | 4112 | self.assertIn(u'cannot create Git repositories owned by' | 4111 | self.assertIn('cannot create Git repositories owned by' |
2257 | 4113 | u' AndrĆ© LuĆs Lopes', response.body.decode('utf-8')) | 4112 | ' AndrĆ© LuĆs Lopes', response.body.decode('utf-8')) |
2258 | 4114 | 4113 | ||
2259 | 4115 | def assertGetRepositoriesWorks(self, target_db): | 4114 | def assertGetRepositoriesWorks(self, target_db): |
2260 | 4116 | if IPerson.providedBy(target_db): | 4115 | if IPerson.providedBy(target_db): |
2261 | @@ -4978,7 +4977,7 @@ class TestRevisionStatusReportWebservice(TestCaseWithFactory): | |||
2262 | 4978 | layer = LaunchpadFunctionalLayer | 4977 | layer = LaunchpadFunctionalLayer |
2263 | 4979 | 4978 | ||
2264 | 4980 | def setUp(self): | 4979 | def setUp(self): |
2266 | 4981 | super(TestRevisionStatusReportWebservice, self).setUp() | 4980 | super().setUp() |
2267 | 4982 | self.repository = self.factory.makeGitRepository() | 4981 | self.repository = self.factory.makeGitRepository() |
2268 | 4983 | self.requester = self.repository.owner | 4982 | self.requester = self.repository.owner |
2269 | 4984 | title = self.factory.getUniqueUnicode('report-title') | 4983 | title = self.factory.getUniqueUnicode('report-title') |
2270 | @@ -5034,7 +5033,7 @@ class TestGitRepositoryMacaroonIssuer(MacaroonTestMixin, TestCaseWithFactory): | |||
2271 | 5034 | layer = DatabaseFunctionalLayer | 5033 | layer = DatabaseFunctionalLayer |
2272 | 5035 | 5034 | ||
2273 | 5036 | def setUp(self): | 5035 | def setUp(self): |
2275 | 5037 | super(TestGitRepositoryMacaroonIssuer, self).setUp() | 5036 | super().setUp() |
2276 | 5038 | self.pushConfig("codehosting", git_macaroon_secret_key="some-secret") | 5037 | self.pushConfig("codehosting", git_macaroon_secret_key="some-secret") |
2277 | 5039 | 5038 | ||
2278 | 5040 | def test_issueMacaroon_refuses_branch(self): | 5039 | def test_issueMacaroon_refuses_branch(self): |
2279 | diff --git a/lib/lp/code/model/tests/test_revision.py b/lib/lp/code/model/tests/test_revision.py | |||
2280 | index 957f2ca..bdd0f7a 100644 | |||
2281 | --- a/lib/lp/code/model/tests/test_revision.py | |||
2282 | +++ b/lib/lp/code/model/tests/test_revision.py | |||
2283 | @@ -204,7 +204,7 @@ class TestRevisionSet(TestCaseWithFactory): | |||
2284 | 204 | layer = DatabaseFunctionalLayer | 204 | layer = DatabaseFunctionalLayer |
2285 | 205 | 205 | ||
2286 | 206 | def setUp(self): | 206 | def setUp(self): |
2288 | 207 | super(TestRevisionSet, self).setUp() | 207 | super().setUp() |
2289 | 208 | self.revision_set = getUtility(IRevisionSet) | 208 | self.revision_set = getUtility(IRevisionSet) |
2290 | 209 | 209 | ||
2291 | 210 | def test_getRevisionById_existing(self): | 210 | def test_getRevisionById_existing(self): |
2292 | diff --git a/lib/lp/code/model/tests/test_revisionauthor.py b/lib/lp/code/model/tests/test_revisionauthor.py | |||
2293 | index 4953571..9941c7f 100644 | |||
2294 | --- a/lib/lp/code/model/tests/test_revisionauthor.py | |||
2295 | +++ b/lib/lp/code/model/tests/test_revisionauthor.py | |||
2296 | @@ -35,7 +35,7 @@ class TestRevisionEmailExtraction(TestCase): | |||
2297 | 35 | layer = LaunchpadZopelessLayer | 35 | layer = LaunchpadZopelessLayer |
2298 | 36 | 36 | ||
2299 | 37 | def setUp(self): | 37 | def setUp(self): |
2301 | 38 | super(TestRevisionEmailExtraction, self).setUp() | 38 | super().setUp() |
2302 | 39 | switch_dbuser("branchscanner") | 39 | switch_dbuser("branchscanner") |
2303 | 40 | 40 | ||
2304 | 41 | def test_email_extracted_from_name(self): | 41 | def test_email_extracted_from_name(self): |
2305 | @@ -134,7 +134,7 @@ class TestNewlyValidatedEmailsLinkRevisionAuthors(MakeHarryTestCase): | |||
2306 | 134 | 134 | ||
2307 | 135 | def setUp(self): | 135 | def setUp(self): |
2308 | 136 | # Create a revision author that doesn't have a user yet. | 136 | # Create a revision author that doesn't have a user yet. |
2310 | 137 | super(TestNewlyValidatedEmailsLinkRevisionAuthors, self).setUp() | 137 | super().setUp() |
2311 | 138 | with dbuser("branchscanner"): | 138 | with dbuser("branchscanner"): |
2312 | 139 | self.author = RevisionSet()._createRevisionAuthor( | 139 | self.author = RevisionSet()._createRevisionAuthor( |
2313 | 140 | '"Harry Potter" <harry@canonical.com>') | 140 | '"Harry Potter" <harry@canonical.com>') |
2314 | @@ -171,35 +171,35 @@ class TestRevisionAuthor(TestCase): | |||
2315 | 171 | layer = LaunchpadZopelessLayer | 171 | layer = LaunchpadZopelessLayer |
2316 | 172 | 172 | ||
2317 | 173 | def setUp(self): | 173 | def setUp(self): |
2319 | 174 | super(TestRevisionAuthor, self).setUp() | 174 | super().setUp() |
2320 | 175 | switch_dbuser("branchscanner") | 175 | switch_dbuser("branchscanner") |
2321 | 176 | 176 | ||
2322 | 177 | def testGetNameWithoutEmailReturnsNamePart(self): | 177 | def testGetNameWithoutEmailReturnsNamePart(self): |
2323 | 178 | # name_without_email is equal to the 'name' part of the revision | 178 | # name_without_email is equal to the 'name' part of the revision |
2324 | 179 | # author information. | 179 | # author information. |
2327 | 180 | author = RevisionAuthor(name=u'Jonathan Lange <jml@canonical.com>') | 180 | author = RevisionAuthor(name='Jonathan Lange <jml@canonical.com>') |
2328 | 181 | self.assertEqual(u'Jonathan Lange', author.name_without_email) | 181 | self.assertEqual('Jonathan Lange', author.name_without_email) |
2329 | 182 | 182 | ||
2330 | 183 | def testGetNameWithoutEmailWithNoName(self): | 183 | def testGetNameWithoutEmailWithNoName(self): |
2331 | 184 | # If there is no name in the revision author information, | 184 | # If there is no name in the revision author information, |
2332 | 185 | # name_without_email is an empty string. | 185 | # name_without_email is an empty string. |
2334 | 186 | author = RevisionAuthor(name=u'jml@mumak.net') | 186 | author = RevisionAuthor(name='jml@mumak.net') |
2335 | 187 | self.assertEqual('', author.name_without_email) | 187 | self.assertEqual('', author.name_without_email) |
2336 | 188 | 188 | ||
2337 | 189 | def testGetNameWithoutEmailWithNoEmail(self): | 189 | def testGetNameWithoutEmailWithNoEmail(self): |
2338 | 190 | # If there is no email in the revision author information, | 190 | # If there is no email in the revision author information, |
2339 | 191 | # name_without_email is the name. | 191 | # name_without_email is the name. |
2341 | 192 | author = RevisionAuthor(name=u'Jonathan Lange') | 192 | author = RevisionAuthor(name='Jonathan Lange') |
2342 | 193 | self.assertEqual('Jonathan Lange', author.name_without_email) | 193 | self.assertEqual('Jonathan Lange', author.name_without_email) |
2343 | 194 | 194 | ||
2344 | 195 | def testGetNameWithoutEmailWithOneWord(self): | 195 | def testGetNameWithoutEmailWithOneWord(self): |
2345 | 196 | # If there is no email in the revision author information, | 196 | # If there is no email in the revision author information, |
2346 | 197 | # name_without_email is the name. | 197 | # name_without_email is the name. |
2348 | 198 | author = RevisionAuthor(name=u'Jonathan.Lange') | 198 | author = RevisionAuthor(name='Jonathan.Lange') |
2349 | 199 | self.assertEqual('Jonathan.Lange', author.name_without_email) | 199 | self.assertEqual('Jonathan.Lange', author.name_without_email) |
2350 | 200 | 200 | ||
2351 | 201 | def testGetNameWithoutEmailWithBadEmail(self): | 201 | def testGetNameWithoutEmailWithBadEmail(self): |
2352 | 202 | # If there is an invalid email in the revision author information, | 202 | # If there is an invalid email in the revision author information, |
2353 | 203 | # name_without_email is an empty string. | 203 | # name_without_email is an empty string. |
2355 | 204 | author = RevisionAuthor(name=u'jml@localhost') | 204 | author = RevisionAuthor(name='jml@localhost') |
2356 | 205 | self.assertEqual('', author.name_without_email) | 205 | self.assertEqual('', author.name_without_email) |
2357 | diff --git a/lib/lp/code/model/tests/test_sourcepackagerecipe.py b/lib/lp/code/model/tests/test_sourcepackagerecipe.py | |||
2358 | index 719ab3b..4837166 100644 | |||
2359 | --- a/lib/lp/code/model/tests/test_sourcepackagerecipe.py | |||
2360 | +++ b/lib/lp/code/model/tests/test_sourcepackagerecipe.py | |||
2361 | @@ -859,7 +859,7 @@ class TestRecipeBranchRoundTrippingMixin: | |||
2362 | 859 | layer = DatabaseFunctionalLayer | 859 | layer = DatabaseFunctionalLayer |
2363 | 860 | 860 | ||
2364 | 861 | def setUp(self): | 861 | def setUp(self): |
2366 | 862 | super(TestRecipeBranchRoundTrippingMixin, self).setUp() | 862 | super().setUp() |
2367 | 863 | self.base_branch = self.makeBranch() | 863 | self.base_branch = self.makeBranch() |
2368 | 864 | self.nested_branch = self.makeBranch() | 864 | self.nested_branch = self.makeBranch() |
2369 | 865 | self.merged_branch = self.makeBranch() | 865 | self.merged_branch = self.makeBranch() |
2370 | diff --git a/lib/lp/code/scripts/repackgitrepository.py b/lib/lp/code/scripts/repackgitrepository.py | |||
2371 | index 9a202a4..6c880da 100644 | |||
2372 | --- a/lib/lp/code/scripts/repackgitrepository.py | |||
2373 | +++ b/lib/lp/code/scripts/repackgitrepository.py | |||
2374 | @@ -6,7 +6,6 @@ | |||
2375 | 6 | from datetime import timedelta | 6 | from datetime import timedelta |
2376 | 7 | 7 | ||
2377 | 8 | from psycopg2.extensions import TransactionRollbackError | 8 | from psycopg2.extensions import TransactionRollbackError |
2378 | 9 | import six | ||
2379 | 10 | from storm.expr import ( | 9 | from storm.expr import ( |
2380 | 11 | Cast, | 10 | Cast, |
2381 | 12 | Or, | 11 | Or, |
2382 | @@ -33,7 +32,7 @@ class RepackTunableLoop(TunableLoop): | |||
2383 | 33 | targets = 1000 | 32 | targets = 1000 |
2384 | 34 | 33 | ||
2385 | 35 | def __init__(self, log, dry_run, abort_time=None): | 34 | def __init__(self, log, dry_run, abort_time=None): |
2387 | 36 | super(RepackTunableLoop, self).__init__(log, abort_time) | 35 | super().__init__(log, abort_time) |
2388 | 37 | self.dry_run = dry_run | 36 | self.dry_run = dry_run |
2389 | 38 | self.start_at = 0 | 37 | self.start_at = 0 |
2390 | 39 | self.logger = log | 38 | self.logger = log |
2391 | @@ -103,7 +102,7 @@ class RepackTunableLoop(TunableLoop): | |||
2392 | 103 | except TransactionRollbackError as error: | 102 | except TransactionRollbackError as error: |
2393 | 104 | self.logger.error( | 103 | self.logger.error( |
2394 | 105 | 'An error occurred while requesting repository repack %s' | 104 | 'An error occurred while requesting repository repack %s' |
2396 | 106 | % six.text_type(error)) | 105 | % str(error)) |
2397 | 107 | if transaction is not None: | 106 | if transaction is not None: |
2398 | 108 | transaction.abort() | 107 | transaction.abort() |
2399 | 109 | continue | 108 | continue |
2400 | diff --git a/lib/lp/code/scripts/tests/test_repack_git_repositories.py b/lib/lp/code/scripts/tests/test_repack_git_repositories.py | |||
2401 | index 9314997..77d1fad 100644 | |||
2402 | --- a/lib/lp/code/scripts/tests/test_repack_git_repositories.py | |||
2403 | +++ b/lib/lp/code/scripts/tests/test_repack_git_repositories.py | |||
2404 | @@ -52,7 +52,7 @@ class FakeTurnipServer(threading.Thread): | |||
2405 | 52 | """Thread that runs a fake turnip server.""" | 52 | """Thread that runs a fake turnip server.""" |
2406 | 53 | 53 | ||
2407 | 54 | def __init__(self): | 54 | def __init__(self): |
2409 | 55 | super(FakeTurnipServer, self).__init__() | 55 | super().__init__() |
2410 | 56 | self.name = 'FakeTurnipServer' | 56 | self.name = 'FakeTurnipServer' |
2411 | 57 | self.app = FakeTurnipApplication() | 57 | self.app = FakeTurnipApplication() |
2412 | 58 | self.server = make_server( | 58 | self.server = make_server( |
2413 | @@ -74,7 +74,7 @@ class TestRequestGitRepack(TestCaseWithFactory): | |||
2414 | 74 | layer = ZopelessAppServerLayer | 74 | layer = ZopelessAppServerLayer |
2415 | 75 | 75 | ||
2416 | 76 | def setUp(self): | 76 | def setUp(self): |
2418 | 77 | super(TestRequestGitRepack, self).setUp() | 77 | super().setUp() |
2419 | 78 | self.log = logging.getLogger('repack') | 78 | self.log = logging.getLogger('repack') |
2420 | 79 | 79 | ||
2421 | 80 | def runScript_no_Turnip(self): | 80 | def runScript_no_Turnip(self): |
2422 | diff --git a/lib/lp/code/scripts/tests/test_request_daily_builds.py b/lib/lp/code/scripts/tests/test_request_daily_builds.py | |||
2423 | index d1ac03a..0d9b970 100644 | |||
2424 | --- a/lib/lp/code/scripts/tests/test_request_daily_builds.py | |||
2425 | +++ b/lib/lp/code/scripts/tests/test_request_daily_builds.py | |||
2426 | @@ -102,7 +102,7 @@ class FakeLoggerheadServer(threading.Thread): | |||
2427 | 102 | """Thread that runs a fake loggerhead server.""" | 102 | """Thread that runs a fake loggerhead server.""" |
2428 | 103 | 103 | ||
2429 | 104 | def __init__(self): | 104 | def __init__(self): |
2431 | 105 | super(FakeLoggerheadServer, self).__init__() | 105 | super().__init__() |
2432 | 106 | self.app = FakeLoggerheadApplication() | 106 | self.app = FakeLoggerheadApplication() |
2433 | 107 | self.server = make_server( | 107 | self.server = make_server( |
2434 | 108 | 'localhost', 0, self.app, handler_class=SilentWSGIRequestHandler) | 108 | 'localhost', 0, self.app, handler_class=SilentWSGIRequestHandler) |
2435 | @@ -162,7 +162,7 @@ class FakeTurnipServer(threading.Thread): | |||
2436 | 162 | """Thread that runs a fake turnip server.""" | 162 | """Thread that runs a fake turnip server.""" |
2437 | 163 | 163 | ||
2438 | 164 | def __init__(self): | 164 | def __init__(self): |
2440 | 165 | super(FakeTurnipServer, self).__init__() | 165 | super().__init__() |
2441 | 166 | self.app = FakeTurnipApplication() | 166 | self.app = FakeTurnipApplication() |
2442 | 167 | self.server = make_server( | 167 | self.server = make_server( |
2443 | 168 | 'localhost', 0, self.app, handler_class=SilentWSGIRequestHandler) | 168 | 'localhost', 0, self.app, handler_class=SilentWSGIRequestHandler) |
2444 | @@ -186,7 +186,7 @@ class TestRequestDailyBuilds(TestCaseWithFactory): | |||
2445 | 186 | layer = ZopelessAppServerLayer | 186 | layer = ZopelessAppServerLayer |
2446 | 187 | 187 | ||
2447 | 188 | def setUp(self): | 188 | def setUp(self): |
2449 | 189 | super(TestRequestDailyBuilds, self).setUp() | 189 | super().setUp() |
2450 | 190 | features = dict(SNAP_TESTING_FLAGS) | 190 | features = dict(SNAP_TESTING_FLAGS) |
2451 | 191 | features[CHARM_RECIPE_ALLOW_CREATE] = "on" | 191 | features[CHARM_RECIPE_ALLOW_CREATE] = "on" |
2452 | 192 | self.useFixture(FeatureFixture(features)) | 192 | self.useFixture(FeatureFixture(features)) |
2453 | diff --git a/lib/lp/code/tests/helpers.py b/lib/lp/code/tests/helpers.py | |||
2454 | index a240ab4..f566b60 100644 | |||
2455 | --- a/lib/lp/code/tests/helpers.py | |||
2456 | +++ b/lib/lp/code/tests/helpers.py | |||
2457 | @@ -150,8 +150,7 @@ def consistent_branch_names(): | |||
2458 | 150 | 150 | ||
2459 | 151 | This generator does not finish! | 151 | This generator does not finish! |
2460 | 152 | """ | 152 | """ |
2463 | 153 | for name in ['trunk', 'testing', 'feature-x', 'feature-y', 'feature-z']: | 153 | yield from ['trunk', 'testing', 'feature-x', 'feature-y', 'feature-z'] |
2462 | 154 | yield name | ||
2464 | 155 | index = count(1) | 154 | index = count(1) |
2465 | 156 | while True: | 155 | while True: |
2466 | 157 | yield "branch-%s" % next(index) | 156 | yield "branch-%s" % next(index) |
2467 | diff --git a/lib/lp/code/tests/test_branch.py b/lib/lp/code/tests/test_branch.py | |||
2468 | index a9e704d..5b316f3 100644 | |||
2469 | --- a/lib/lp/code/tests/test_branch.py | |||
2470 | +++ b/lib/lp/code/tests/test_branch.py | |||
2471 | @@ -331,7 +331,7 @@ class TestComposePublicURL(TestCaseWithFactory): | |||
2472 | 331 | layer = DatabaseFunctionalLayer | 331 | layer = DatabaseFunctionalLayer |
2473 | 332 | 332 | ||
2474 | 333 | def setUp(self): | 333 | def setUp(self): |
2476 | 334 | super(TestComposePublicURL, self).setUp('admin@canonical.com') | 334 | super().setUp('admin@canonical.com') |
2477 | 335 | 335 | ||
2478 | 336 | def test_composePublicURL_accepts_supported_schemes(self): | 336 | def test_composePublicURL_accepts_supported_schemes(self): |
2479 | 337 | # composePublicURL accepts all schemes that PublicCodehostingAPI | 337 | # composePublicURL accepts all schemes that PublicCodehostingAPI |
2480 | diff --git a/lib/lp/code/tests/test_branch_webservice.py b/lib/lp/code/tests/test_branch_webservice.py | |||
2481 | index 653ea5c..0a7e495 100644 | |||
2482 | --- a/lib/lp/code/tests/test_branch_webservice.py | |||
2483 | +++ b/lib/lp/code/tests/test_branch_webservice.py | |||
2484 | @@ -175,7 +175,7 @@ class TestBranchDeletes(TestCaseWithFactory): | |||
2485 | 175 | layer = DatabaseFunctionalLayer | 175 | layer = DatabaseFunctionalLayer |
2486 | 176 | 176 | ||
2487 | 177 | def setUp(self): | 177 | def setUp(self): |
2489 | 178 | super(TestBranchDeletes, self).setUp() | 178 | super().setUp() |
2490 | 179 | self.branch_owner = self.factory.makePerson(name='jimhenson') | 179 | self.branch_owner = self.factory.makePerson(name='jimhenson') |
2491 | 180 | self.branch = self.factory.makeBranch( | 180 | self.branch = self.factory.makeBranch( |
2492 | 181 | owner=self.branch_owner, | 181 | owner=self.branch_owner, |
2493 | diff --git a/lib/lp/code/tests/test_bzr.py b/lib/lp/code/tests/test_bzr.py | |||
2494 | index 7f6939c..d430ad0 100644 | |||
2495 | --- a/lib/lp/code/tests/test_bzr.py | |||
2496 | +++ b/lib/lp/code/tests/test_bzr.py | |||
2497 | @@ -9,7 +9,6 @@ from breezy.tests import ( | |||
2498 | 9 | TestCaseInTempDir, | 9 | TestCaseInTempDir, |
2499 | 10 | TestCaseWithTransport, | 10 | TestCaseWithTransport, |
2500 | 11 | ) | 11 | ) |
2501 | 12 | import six | ||
2502 | 13 | 12 | ||
2503 | 14 | from lp.code.bzr import ( | 13 | from lp.code.bzr import ( |
2504 | 15 | branch_revision_history, | 14 | branch_revision_history, |
2505 | @@ -46,7 +45,7 @@ class TestGetBranchFormats(TestCaseInTempDir): | |||
2506 | 46 | 45 | ||
2507 | 47 | def test_get_branch_format_2a(self): | 46 | def test_get_branch_format_2a(self): |
2508 | 48 | # Test the 2a branch format. | 47 | # Test the 2a branch format. |
2510 | 49 | branch = self.make_branch('test', six.ensure_str('2a')) | 48 | branch = self.make_branch('test', '2a') |
2511 | 50 | formats = get_branch_formats(branch) | 49 | formats = get_branch_formats(branch) |
2512 | 51 | self.assertEqual(ControlFormat.BZR_METADIR_1, formats[0]) | 50 | self.assertEqual(ControlFormat.BZR_METADIR_1, formats[0]) |
2513 | 52 | self.assertEqual(BranchFormat.BZR_BRANCH_7, formats[1]) | 51 | self.assertEqual(BranchFormat.BZR_BRANCH_7, formats[1]) |
2514 | @@ -54,7 +53,7 @@ class TestGetBranchFormats(TestCaseInTempDir): | |||
2515 | 54 | 53 | ||
2516 | 55 | def test_get_branch_format_1_9(self): | 54 | def test_get_branch_format_1_9(self): |
2517 | 56 | # Test the 1.9 branch format. | 55 | # Test the 1.9 branch format. |
2519 | 57 | branch = self.make_branch('test', six.ensure_str('1.9')) | 56 | branch = self.make_branch('test', '1.9') |
2520 | 58 | formats = get_branch_formats(branch) | 57 | formats = get_branch_formats(branch) |
2521 | 59 | self.assertEqual(ControlFormat.BZR_METADIR_1, formats[0]) | 58 | self.assertEqual(ControlFormat.BZR_METADIR_1, formats[0]) |
2522 | 60 | self.assertEqual(BranchFormat.BZR_BRANCH_7, formats[1]) | 59 | self.assertEqual(BranchFormat.BZR_BRANCH_7, formats[1]) |
2523 | @@ -62,7 +61,7 @@ class TestGetBranchFormats(TestCaseInTempDir): | |||
2524 | 62 | 61 | ||
2525 | 63 | def test_get_branch_format_packs(self): | 62 | def test_get_branch_format_packs(self): |
2526 | 64 | # Test the packs branch format. | 63 | # Test the packs branch format. |
2528 | 65 | branch = self.make_branch('test', six.ensure_str('pack-0.92')) | 64 | branch = self.make_branch('test', 'pack-0.92') |
2529 | 66 | formats = get_branch_formats(branch) | 65 | formats = get_branch_formats(branch) |
2530 | 67 | self.assertEqual(ControlFormat.BZR_METADIR_1, formats[0]) | 66 | self.assertEqual(ControlFormat.BZR_METADIR_1, formats[0]) |
2531 | 68 | self.assertEqual(BranchFormat.BZR_BRANCH_6, formats[1]) | 67 | self.assertEqual(BranchFormat.BZR_BRANCH_6, formats[1]) |
2532 | @@ -70,7 +69,7 @@ class TestGetBranchFormats(TestCaseInTempDir): | |||
2533 | 70 | 69 | ||
2534 | 71 | def test_get_branch_format_knits(self): | 70 | def test_get_branch_format_knits(self): |
2535 | 72 | # Test the knits branch format. | 71 | # Test the knits branch format. |
2537 | 73 | branch = self.make_branch('test', six.ensure_str('knit')) | 72 | branch = self.make_branch('test', 'knit') |
2538 | 74 | formats = get_branch_formats(branch) | 73 | formats = get_branch_formats(branch) |
2539 | 75 | self.assertEqual(ControlFormat.BZR_METADIR_1, formats[0]) | 74 | self.assertEqual(ControlFormat.BZR_METADIR_1, formats[0]) |
2540 | 76 | self.assertEqual(BranchFormat.BZR_BRANCH_5, formats[1]) | 75 | self.assertEqual(BranchFormat.BZR_BRANCH_5, formats[1]) |
2541 | diff --git a/lib/lp/code/tests/test_directbranchcommit.py b/lib/lp/code/tests/test_directbranchcommit.py | |||
2542 | index 977d855..db4d71c 100644 | |||
2543 | --- a/lib/lp/code/tests/test_directbranchcommit.py | |||
2544 | +++ b/lib/lp/code/tests/test_directbranchcommit.py | |||
2545 | @@ -30,7 +30,7 @@ class DirectBranchCommitTestCase: | |||
2546 | 30 | committer = None | 30 | committer = None |
2547 | 31 | 31 | ||
2548 | 32 | def setUp(self): | 32 | def setUp(self): |
2550 | 33 | super(DirectBranchCommitTestCase, self).setUp() | 33 | super().setUp() |
2551 | 34 | self.useBzrBranches(direct_database=True) | 34 | self.useBzrBranches(direct_database=True) |
2552 | 35 | 35 | ||
2553 | 36 | self.series = self.factory.makeProductSeries() | 36 | self.series = self.factory.makeProductSeries() |
2554 | @@ -292,7 +292,7 @@ class TestGetBzrCommitterID(TestCaseWithFactory): | |||
2555 | 292 | layer = DatabaseFunctionalLayer | 292 | layer = DatabaseFunctionalLayer |
2556 | 293 | 293 | ||
2557 | 294 | def setUp(self): | 294 | def setUp(self): |
2559 | 295 | super(TestGetBzrCommitterID, self).setUp() | 295 | super().setUp() |
2560 | 296 | self.useBzrBranches(direct_database=True) | 296 | self.useBzrBranches(direct_database=True) |
2561 | 297 | 297 | ||
2562 | 298 | def _makeBranch(self, **kwargs): | 298 | def _makeBranch(self, **kwargs): |
2563 | diff --git a/lib/lp/code/tests/test_project.py b/lib/lp/code/tests/test_project.py | |||
2564 | index d765060..7230a94 100644 | |||
2565 | --- a/lib/lp/code/tests/test_project.py | |||
2566 | +++ b/lib/lp/code/tests/test_project.py | |||
2567 | @@ -12,7 +12,7 @@ class TestProjectBranches(TestCaseWithFactory): | |||
2568 | 12 | layer = DatabaseFunctionalLayer | 12 | layer = DatabaseFunctionalLayer |
2569 | 13 | 13 | ||
2570 | 14 | def setUp(self): | 14 | def setUp(self): |
2572 | 15 | super(TestProjectBranches, self).setUp() | 15 | super().setUp() |
2573 | 16 | self.projectgroup = self.factory.makeProject() | 16 | self.projectgroup = self.factory.makeProject() |
2574 | 17 | self.product = self.factory.makeProduct(projectgroup=self.projectgroup) | 17 | self.product = self.factory.makeProduct(projectgroup=self.projectgroup) |
2575 | 18 | 18 | ||
2576 | diff --git a/lib/lp/code/vocabularies/branch.py b/lib/lp/code/vocabularies/branch.py | |||
2577 | index b165edc..d1b5eb9 100644 | |||
2578 | --- a/lib/lp/code/vocabularies/branch.py | |||
2579 | +++ b/lib/lp/code/vocabularies/branch.py | |||
2580 | @@ -70,7 +70,7 @@ class BranchRestrictedOnProductVocabulary(BranchVocabulary): | |||
2581 | 70 | """A vocabulary for searching branches restricted on product.""" | 70 | """A vocabulary for searching branches restricted on product.""" |
2582 | 71 | 71 | ||
2583 | 72 | def __init__(self, context=None): | 72 | def __init__(self, context=None): |
2585 | 73 | super(BranchRestrictedOnProductVocabulary, self).__init__(context) | 73 | super().__init__(context) |
2586 | 74 | if IProduct.providedBy(self.context): | 74 | if IProduct.providedBy(self.context): |
2587 | 75 | self.product = self.context | 75 | self.product = self.context |
2588 | 76 | elif IProductSeries.providedBy(self.context): | 76 | elif IProductSeries.providedBy(self.context): |
2589 | @@ -94,7 +94,7 @@ class HostedBranchRestrictedOnOwnerVocabulary(BranchVocabulary): | |||
2590 | 94 | 94 | ||
2591 | 95 | def __init__(self, context=None): | 95 | def __init__(self, context=None): |
2592 | 96 | """Pass a Person as context, or anything else for the current user.""" | 96 | """Pass a Person as context, or anything else for the current user.""" |
2594 | 97 | super(HostedBranchRestrictedOnOwnerVocabulary, self).__init__(context) | 97 | super().__init__(context) |
2595 | 98 | if IPerson.providedBy(self.context): | 98 | if IPerson.providedBy(self.context): |
2596 | 99 | self.user = self.context | 99 | self.user = self.context |
2597 | 100 | else: | 100 | else: |
2598 | diff --git a/lib/lp/code/vocabularies/gitref.py b/lib/lp/code/vocabularies/gitref.py | |||
2599 | index de842d1..2a2bad3 100644 | |||
2600 | --- a/lib/lp/code/vocabularies/gitref.py | |||
2601 | +++ b/lib/lp/code/vocabularies/gitref.py | |||
2602 | @@ -59,7 +59,7 @@ class GitRefVocabulary(StormVocabularyBase): | |||
2603 | 59 | step_title = "Search" | 59 | step_title = "Search" |
2604 | 60 | 60 | ||
2605 | 61 | def __init__(self, context): | 61 | def __init__(self, context): |
2607 | 62 | super(GitRefVocabulary, self).__init__(context=context) | 62 | super().__init__(context=context) |
2608 | 63 | if IReference.providedBy(context): | 63 | if IReference.providedBy(context): |
2609 | 64 | context = context.context | 64 | context = context.context |
2610 | 65 | try: | 65 | try: |
2611 | @@ -135,7 +135,7 @@ class GitRefVocabulary(StormVocabularyBase): | |||
2612 | 135 | # remote refs aren't database backed | 135 | # remote refs aren't database backed |
2613 | 136 | if zope_isinstance(value, GitRefRemote): | 136 | if zope_isinstance(value, GitRefRemote): |
2614 | 137 | return self.toTerm(value) | 137 | return self.toTerm(value) |
2616 | 138 | return super(GitRefVocabulary, self).getTerm(value) | 138 | return super().getTerm(value) |
2617 | 139 | 139 | ||
2618 | 140 | def __len__(self): | 140 | def __len__(self): |
2619 | 141 | """See `IVocabulary`.""" | 141 | """See `IVocabulary`.""" |
2620 | diff --git a/lib/lp/code/vocabularies/gitrepository.py b/lib/lp/code/vocabularies/gitrepository.py | |||
2621 | index 4f6f9df..92f8c3c 100644 | |||
2622 | --- a/lib/lp/code/vocabularies/gitrepository.py | |||
2623 | +++ b/lib/lp/code/vocabularies/gitrepository.py | |||
2624 | @@ -67,8 +67,7 @@ class GitRepositoryRestrictedOnProductVocabulary(GitRepositoryVocabulary): | |||
2625 | 67 | """A vocabulary for searching git repositories restricted on product.""" | 67 | """A vocabulary for searching git repositories restricted on product.""" |
2626 | 68 | 68 | ||
2627 | 69 | def __init__(self, context): | 69 | def __init__(self, context): |
2630 | 70 | super(GitRepositoryRestrictedOnProductVocabulary, self).__init__( | 70 | super().__init__(context) |
2629 | 71 | context) | ||
2631 | 72 | if IProduct.providedBy(self.context): | 71 | if IProduct.providedBy(self.context): |
2632 | 73 | self.product = self.context | 72 | self.product = self.context |
2633 | 74 | else: | 73 | else: |
2634 | diff --git a/lib/lp/code/vocabularies/gitrule.py b/lib/lp/code/vocabularies/gitrule.py | |||
2635 | index 4b6284b..f6be79b 100644 | |||
2636 | --- a/lib/lp/code/vocabularies/gitrule.py | |||
2637 | +++ b/lib/lp/code/vocabularies/gitrule.py | |||
2638 | @@ -102,4 +102,4 @@ class GitPermissionsVocabulary(SimpleVocabulary): | |||
2639 | 102 | terms.append(SimpleTerm( | 102 | terms.append(SimpleTerm( |
2640 | 103 | grant_permissions, | 103 | grant_permissions, |
2641 | 104 | "custom", "Custom permissions: %s" % ", ".join(names))) | 104 | "custom", "Custom permissions: %s" % ", ".join(names))) |
2643 | 105 | super(GitPermissionsVocabulary, self).__init__(terms) | 105 | super().__init__(terms) |
2644 | diff --git a/lib/lp/code/vocabularies/tests/test_branch_vocabularies.py b/lib/lp/code/vocabularies/tests/test_branch_vocabularies.py | |||
2645 | index 7773c17..23d018f 100644 | |||
2646 | --- a/lib/lp/code/vocabularies/tests/test_branch_vocabularies.py | |||
2647 | +++ b/lib/lp/code/vocabularies/tests/test_branch_vocabularies.py | |||
2648 | @@ -22,7 +22,7 @@ class TestBranchVocabulary(TestCaseWithFactory): | |||
2649 | 22 | layer = DatabaseFunctionalLayer | 22 | layer = DatabaseFunctionalLayer |
2650 | 23 | 23 | ||
2651 | 24 | def setUp(self): | 24 | def setUp(self): |
2653 | 25 | super(TestBranchVocabulary, self).setUp() | 25 | super().setUp() |
2654 | 26 | self._createBranches() | 26 | self._createBranches() |
2655 | 27 | self.vocab = BranchVocabulary(context=None) | 27 | self.vocab = BranchVocabulary(context=None) |
2656 | 28 | 28 | ||
2657 | @@ -40,8 +40,7 @@ class TestBranchVocabulary(TestCaseWithFactory): | |||
2658 | 40 | def test_fizzbuzzBranches(self): | 40 | def test_fizzbuzzBranches(self): |
2659 | 41 | """Return branches that match the string 'fizzbuzz'.""" | 41 | """Return branches that match the string 'fizzbuzz'.""" |
2660 | 42 | results = self.vocab.searchForTerms('fizzbuzz') | 42 | results = self.vocab.searchForTerms('fizzbuzz') |
2663 | 43 | expected = [ | 43 | expected = ['~scotty/sprocket/fizzbuzz', '~scotty/widget/fizzbuzz'] |
2662 | 44 | u'~scotty/sprocket/fizzbuzz', u'~scotty/widget/fizzbuzz'] | ||
2664 | 45 | branch_names = sorted(branch.token for branch in results) | 44 | branch_names = sorted(branch.token for branch in results) |
2665 | 46 | self.assertEqual(expected, branch_names) | 45 | self.assertEqual(expected, branch_names) |
2666 | 47 | 46 | ||
2667 | @@ -68,7 +67,7 @@ class TestRestrictedBranchVocabularyOnProduct(TestCaseWithFactory): | |||
2668 | 68 | layer = DatabaseFunctionalLayer | 67 | layer = DatabaseFunctionalLayer |
2669 | 69 | 68 | ||
2670 | 70 | def setUp(self): | 69 | def setUp(self): |
2672 | 71 | super(TestRestrictedBranchVocabularyOnProduct, self).setUp() | 70 | super().setUp() |
2673 | 72 | self._createBranches() | 71 | self._createBranches() |
2674 | 73 | self.vocab = BranchRestrictedOnProductVocabulary( | 72 | self.vocab = BranchRestrictedOnProductVocabulary( |
2675 | 74 | context=self._getVocabRestriction()) | 73 | context=self._getVocabRestriction()) |
2676 | @@ -98,7 +97,7 @@ class TestRestrictedBranchVocabularyOnProduct(TestCaseWithFactory): | |||
2677 | 98 | The result set should not show ~scotty/sprocket/main. | 97 | The result set should not show ~scotty/sprocket/main. |
2678 | 99 | """ | 98 | """ |
2679 | 100 | results = self.vocab.searchForTerms('main') | 99 | results = self.vocab.searchForTerms('main') |
2681 | 101 | expected = [u'~scotty/widget/main'] | 100 | expected = ['~scotty/widget/main'] |
2682 | 102 | branch_names = sorted(branch.token for branch in results) | 101 | branch_names = sorted(branch.token for branch in results) |
2683 | 103 | self.assertEqual(expected, branch_names) | 102 | self.assertEqual(expected, branch_names) |
2684 | 104 | 103 | ||
2685 | diff --git a/lib/lp/code/vocabularies/tests/test_gitrepository_vocabularies.py b/lib/lp/code/vocabularies/tests/test_gitrepository_vocabularies.py | |||
2686 | index 774b0a1..d64d8c0 100644 | |||
2687 | --- a/lib/lp/code/vocabularies/tests/test_gitrepository_vocabularies.py | |||
2688 | +++ b/lib/lp/code/vocabularies/tests/test_gitrepository_vocabularies.py | |||
2689 | @@ -20,7 +20,7 @@ class TestGitRepositoryVocabulary(TestCaseWithFactory): | |||
2690 | 20 | layer = DatabaseFunctionalLayer | 20 | layer = DatabaseFunctionalLayer |
2691 | 21 | 21 | ||
2692 | 22 | def setUp(self): | 22 | def setUp(self): |
2694 | 23 | super(TestGitRepositoryVocabulary, self).setUp() | 23 | super().setUp() |
2695 | 24 | self._createRepositories() | 24 | self._createRepositories() |
2696 | 25 | self.vocab = GitRepositoryVocabulary(context=None) | 25 | self.vocab = GitRepositoryVocabulary(context=None) |
2697 | 26 | 26 | ||
2698 | @@ -29,17 +29,17 @@ class TestGitRepositoryVocabulary(TestCaseWithFactory): | |||
2699 | 29 | sprocket = self.factory.makeProduct(name="sprocket") | 29 | sprocket = self.factory.makeProduct(name="sprocket") |
2700 | 30 | scotty = self.factory.makePerson(name="scotty") | 30 | scotty = self.factory.makePerson(name="scotty") |
2701 | 31 | self.factory.makeGitRepository( | 31 | self.factory.makeGitRepository( |
2703 | 32 | owner=scotty, target=widget, name=u"fizzbuzz") | 32 | owner=scotty, target=widget, name="fizzbuzz") |
2704 | 33 | self.factory.makeGitRepository( | 33 | self.factory.makeGitRepository( |
2706 | 34 | owner=scotty, target=widget, name=u"mountain") | 34 | owner=scotty, target=widget, name="mountain") |
2707 | 35 | self.factory.makeGitRepository( | 35 | self.factory.makeGitRepository( |
2709 | 36 | owner=scotty, target=sprocket, name=u"fizzbuzz") | 36 | owner=scotty, target=sprocket, name="fizzbuzz") |
2710 | 37 | 37 | ||
2711 | 38 | def test_fizzbuzzRepositories(self): | 38 | def test_fizzbuzzRepositories(self): |
2712 | 39 | """Return repositories that match the string 'fizzbuzz'.""" | 39 | """Return repositories that match the string 'fizzbuzz'.""" |
2713 | 40 | results = self.vocab.searchForTerms("fizzbuzz") | 40 | results = self.vocab.searchForTerms("fizzbuzz") |
2714 | 41 | expected = [ | 41 | expected = [ |
2716 | 42 | u"~scotty/sprocket/+git/fizzbuzz", u"~scotty/widget/+git/fizzbuzz"] | 42 | "~scotty/sprocket/+git/fizzbuzz", "~scotty/widget/+git/fizzbuzz"] |
2717 | 43 | repository_names = sorted(repository.token for repository in results) | 43 | repository_names = sorted(repository.token for repository in results) |
2718 | 44 | self.assertEqual(expected, repository_names) | 44 | self.assertEqual(expected, repository_names) |
2719 | 45 | 45 | ||
2720 | @@ -67,7 +67,7 @@ class TestRestrictedGitRepositoryVocabularyOnProduct(TestCaseWithFactory): | |||
2721 | 67 | layer = DatabaseFunctionalLayer | 67 | layer = DatabaseFunctionalLayer |
2722 | 68 | 68 | ||
2723 | 69 | def setUp(self): | 69 | def setUp(self): |
2725 | 70 | super(TestRestrictedGitRepositoryVocabularyOnProduct, self).setUp() | 70 | super().setUp() |
2726 | 71 | self._createRepositories() | 71 | self._createRepositories() |
2727 | 72 | self.vocab = GitRepositoryRestrictedOnProductVocabulary( | 72 | self.vocab = GitRepositoryRestrictedOnProductVocabulary( |
2728 | 73 | context=self._getVocabRestriction()) | 73 | context=self._getVocabRestriction()) |
2729 | @@ -79,11 +79,11 @@ class TestRestrictedGitRepositoryVocabularyOnProduct(TestCaseWithFactory): | |||
2730 | 79 | def _createRepositories(self): | 79 | def _createRepositories(self): |
2731 | 80 | test_product = self.factory.makeProduct(name='widget') | 80 | test_product = self.factory.makeProduct(name='widget') |
2732 | 81 | other_product = self.factory.makeProduct(name='sprocket') | 81 | other_product = self.factory.makeProduct(name='sprocket') |
2734 | 82 | person = self.factory.makePerson(name=u'scotty') | 82 | person = self.factory.makePerson(name='scotty') |
2735 | 83 | self.factory.makeGitRepository( | 83 | self.factory.makeGitRepository( |
2737 | 84 | owner=person, target=test_product, name=u'mountain') | 84 | owner=person, target=test_product, name='mountain') |
2738 | 85 | self.factory.makeGitRepository( | 85 | self.factory.makeGitRepository( |
2740 | 86 | owner=person, target=other_product, name=u'mountain') | 86 | owner=person, target=other_product, name='mountain') |
2741 | 87 | self.product = test_product | 87 | self.product = test_product |
2742 | 88 | self.other_product = test_product | 88 | self.other_product = test_product |
2743 | 89 | 89 | ||
2744 | @@ -93,7 +93,7 @@ class TestRestrictedGitRepositoryVocabularyOnProduct(TestCaseWithFactory): | |||
2745 | 93 | The result set should not show ~scotty/sprocket/mountain. | 93 | The result set should not show ~scotty/sprocket/mountain. |
2746 | 94 | """ | 94 | """ |
2747 | 95 | results = self.vocab.searchForTerms('mountain') | 95 | results = self.vocab.searchForTerms('mountain') |
2749 | 96 | expected = [u'~scotty/widget/+git/mountain'] | 96 | expected = ['~scotty/widget/+git/mountain'] |
2750 | 97 | repo_names = sorted(repo.token for repo in results) | 97 | repo_names = sorted(repo.token for repo in results) |
2751 | 98 | self.assertEqual(expected, repo_names) | 98 | self.assertEqual(expected, repo_names) |
2752 | 99 | 99 | ||
2753 | @@ -102,7 +102,7 @@ class TestRestrictedGitRepositoryVocabularyOnProduct(TestCaseWithFactory): | |||
2754 | 102 | # as the result. | 102 | # as the result. |
2755 | 103 | term = self.vocab.getTermByToken('mountain') | 103 | term = self.vocab.getTermByToken('mountain') |
2756 | 104 | self.assertEqual( | 104 | self.assertEqual( |
2758 | 105 | u'~scotty/widget/+git/mountain', term.value.unique_name) | 105 | '~scotty/widget/+git/mountain', term.value.unique_name) |
2759 | 106 | 106 | ||
2760 | 107 | def test_multipleQueryResult(self): | 107 | def test_multipleQueryResult(self): |
2761 | 108 | # If there are more than one search result, a LookupError is still | 108 | # If there are more than one search result, a LookupError is still |
2762 | diff --git a/lib/lp/code/xmlrpc/codehosting.py b/lib/lp/code/xmlrpc/codehosting.py | |||
2763 | index c32d69f..07416b0 100644 | |||
2764 | --- a/lib/lp/code/xmlrpc/codehosting.py | |||
2765 | +++ b/lib/lp/code/xmlrpc/codehosting.py | |||
2766 | @@ -109,7 +109,7 @@ def run_with_login(login_id, function, *args, **kwargs): | |||
2767 | 109 | # Don't pass in an actual user. Instead pass in LAUNCHPAD_SERVICES | 109 | # Don't pass in an actual user. Instead pass in LAUNCHPAD_SERVICES |
2768 | 110 | # and expect `function` to use `removeSecurityProxy` or similar. | 110 | # and expect `function` to use `removeSecurityProxy` or similar. |
2769 | 111 | return function(login_id, *args, **kwargs) | 111 | return function(login_id, *args, **kwargs) |
2771 | 112 | if isinstance(login_id, (six.binary_type, six.text_type)): | 112 | if isinstance(login_id, (bytes, str)): |
2772 | 113 | login_id = six.ensure_text(login_id) | 113 | login_id = six.ensure_text(login_id) |
2773 | 114 | # OpenID identifiers must contain a slash, while names must not. | 114 | # OpenID identifiers must contain a slash, while names must not. |
2774 | 115 | if "/" in login_id: | 115 | if "/" in login_id: |
2775 | diff --git a/lib/lp/code/xmlrpc/git.py b/lib/lp/code/xmlrpc/git.py | |||
2776 | index 9278b1a..83383cd 100644 | |||
2777 | --- a/lib/lp/code/xmlrpc/git.py | |||
2778 | +++ b/lib/lp/code/xmlrpc/git.py | |||
2779 | @@ -131,7 +131,7 @@ class GitAPI(LaunchpadXMLRPCView): | |||
2780 | 131 | """See `IGitAPI`.""" | 131 | """See `IGitAPI`.""" |
2781 | 132 | 132 | ||
2782 | 133 | def __init__(self, *args, **kwargs): | 133 | def __init__(self, *args, **kwargs): |
2784 | 134 | super(GitAPI, self).__init__(*args, **kwargs) | 134 | super().__init__(*args, **kwargs) |
2785 | 135 | self.repository_set = getUtility(IGitRepositorySet) | 135 | self.repository_set = getUtility(IGitRepositorySet) |
2786 | 136 | 136 | ||
2787 | 137 | def _verifyMacaroon(self, macaroon_raw, repository=None, user=None): | 137 | def _verifyMacaroon(self, macaroon_raw, repository=None, user=None): |
2788 | @@ -326,7 +326,7 @@ class GitAPI(LaunchpadXMLRPCView): | |||
2789 | 326 | def _reportError(self, path, exception, hosting_path=None): | 326 | def _reportError(self, path, exception, hosting_path=None): |
2790 | 327 | properties = [ | 327 | properties = [ |
2791 | 328 | ("path", path), | 328 | ("path", path), |
2793 | 329 | ("error-explanation", six.text_type(exception)), | 329 | ("error-explanation", str(exception)), |
2794 | 330 | ] | 330 | ] |
2795 | 331 | if hosting_path is not None: | 331 | if hosting_path is not None: |
2796 | 332 | properties.append(("hosting_path", hosting_path)) | 332 | properties.append(("hosting_path", hosting_path)) |
2797 | @@ -360,9 +360,9 @@ class GitAPI(LaunchpadXMLRPCView): | |||
2798 | 360 | raise faults.InvalidSourcePackageName(e.name) | 360 | raise faults.InvalidSourcePackageName(e.name) |
2799 | 361 | return self._createRepository(requester, path) | 361 | return self._createRepository(requester, path) |
2800 | 362 | except NameLookupFailed as e: | 362 | except NameLookupFailed as e: |
2802 | 363 | raise faults.NotFound(six.text_type(e)) | 363 | raise faults.NotFound(str(e)) |
2803 | 364 | except GitRepositoryCreationForbidden as e: | 364 | except GitRepositoryCreationForbidden as e: |
2805 | 365 | raise faults.PermissionDenied(six.text_type(e)) | 365 | raise faults.PermissionDenied(str(e)) |
2806 | 366 | 366 | ||
2807 | 367 | try: | 367 | try: |
2808 | 368 | try: | 368 | try: |
2809 | @@ -391,7 +391,7 @@ class GitAPI(LaunchpadXMLRPCView): | |||
2810 | 391 | # private repository). Log an OOPS for investigation. | 391 | # private repository). Log an OOPS for investigation. |
2811 | 392 | self._reportError(path, e) | 392 | self._reportError(path, e) |
2812 | 393 | except (GitRepositoryCreationException, Unauthorized) as e: | 393 | except (GitRepositoryCreationException, Unauthorized) as e: |
2814 | 394 | raise faults.PermissionDenied(six.text_type(e)) | 394 | raise faults.PermissionDenied(str(e)) |
2815 | 395 | except GitRepositoryCreationFault as e: | 395 | except GitRepositoryCreationFault as e: |
2816 | 396 | # The hosting service failed. Log an OOPS for investigation. | 396 | # The hosting service failed. Log an OOPS for investigation. |
2817 | 397 | self._reportError(path, e, hosting_path=e.path) | 397 | self._reportError(path, e, hosting_path=e.path) |
2818 | diff --git a/lib/lp/code/xmlrpc/tests/test_branch.py b/lib/lp/code/xmlrpc/tests/test_branch.py | |||
2819 | index 41d55d7..58d2192 100644 | |||
2820 | --- a/lib/lp/code/xmlrpc/tests/test_branch.py | |||
2821 | +++ b/lib/lp/code/xmlrpc/tests/test_branch.py | |||
2822 | @@ -24,7 +24,7 @@ from lp.testing.layers import DatabaseFunctionalLayer | |||
2823 | 24 | from lp.xmlrpc import faults | 24 | from lp.xmlrpc import faults |
2824 | 25 | 25 | ||
2825 | 26 | 26 | ||
2827 | 27 | NON_ASCII_NAME = u'nam\N{LATIN SMALL LETTER E WITH ACUTE}' | 27 | NON_ASCII_NAME = 'nam\N{LATIN SMALL LETTER E WITH ACUTE}' |
2828 | 28 | 28 | ||
2829 | 29 | 29 | ||
2830 | 30 | class TestExpandURL(TestCaseWithFactory): | 30 | class TestExpandURL(TestCaseWithFactory): |
2831 | @@ -193,7 +193,7 @@ class TestExpandURL(TestCaseWithFactory): | |||
2832 | 193 | # find a branch, but it still resolves rather than erroring. | 193 | # find a branch, but it still resolves rather than erroring. |
2833 | 194 | owner = self.factory.makePerson() | 194 | owner = self.factory.makePerson() |
2834 | 195 | product = self.factory.makeProduct() | 195 | product = self.factory.makeProduct() |
2836 | 196 | nonexistent_branch = u'~%s/%s/%s' % ( | 196 | nonexistent_branch = '~%s/%s/%s' % ( |
2837 | 197 | owner.name, product.name, NON_ASCII_NAME) | 197 | owner.name, product.name, NON_ASCII_NAME) |
2838 | 198 | self.assertResolves( | 198 | self.assertResolves( |
2839 | 199 | nonexistent_branch, urlutils.escape(nonexistent_branch)) | 199 | nonexistent_branch, urlutils.escape(nonexistent_branch)) |
2840 | @@ -236,7 +236,7 @@ class TestExpandURL(TestCaseWithFactory): | |||
2841 | 236 | def test_resolve_branch_with_no_such_owner_non_ascii(self): | 236 | def test_resolve_branch_with_no_such_owner_non_ascii(self): |
2842 | 237 | # lp:~<non-ascii-string>/product/name returns NoSuchPersonWithName | 237 | # lp:~<non-ascii-string>/product/name returns NoSuchPersonWithName |
2843 | 238 | # with the name escaped. | 238 | # with the name escaped. |
2845 | 239 | nonexistent_owner_branch = u"~%s/%s/%s" % ( | 239 | nonexistent_owner_branch = "~%s/%s/%s" % ( |
2846 | 240 | NON_ASCII_NAME, self.factory.getUniqueString(), | 240 | NON_ASCII_NAME, self.factory.getUniqueString(), |
2847 | 241 | self.factory.getUniqueString()) | 241 | self.factory.getUniqueString()) |
2848 | 242 | self.assertFault( | 242 | self.assertFault( |
2849 | diff --git a/lib/lp/code/xmlrpc/tests/test_codehosting.py b/lib/lp/code/xmlrpc/tests/test_codehosting.py | |||
2850 | index e72e46b..4921642 100644 | |||
2851 | --- a/lib/lp/code/xmlrpc/tests/test_codehosting.py | |||
2852 | +++ b/lib/lp/code/xmlrpc/tests/test_codehosting.py | |||
2853 | @@ -85,7 +85,7 @@ class TestRunWithLogin(TestCaseWithFactory): | |||
2854 | 85 | layer = DatabaseFunctionalLayer | 85 | layer = DatabaseFunctionalLayer |
2855 | 86 | 86 | ||
2856 | 87 | def setUp(self): | 87 | def setUp(self): |
2858 | 88 | super(TestRunWithLogin, self).setUp() | 88 | super().setUp() |
2859 | 89 | self.person = self.factory.makePerson() | 89 | self.person = self.factory.makePerson() |
2860 | 90 | 90 | ||
2861 | 91 | def test_loginAsRequester(self): | 91 | def test_loginAsRequester(self): |
2862 | @@ -114,7 +114,7 @@ class TestRunWithLogin(TestCaseWithFactory): | |||
2863 | 114 | self.person.account.openid_identifiers.one().identifier) | 114 | self.person.account.openid_identifiers.one().identifier) |
2864 | 115 | username = run_with_login( | 115 | username = run_with_login( |
2865 | 116 | # Deliberately not Unicode, since XML-RPC gives us a byte string. | 116 | # Deliberately not Unicode, since XML-RPC gives us a byte string. |
2867 | 117 | (u'http://testopenid.test/+id/%s' % identifier).encode("UTF-8"), | 117 | ('http://testopenid.test/+id/%s' % identifier).encode("UTF-8"), |
2868 | 118 | get_logged_in_username) | 118 | get_logged_in_username) |
2869 | 119 | login(ANONYMOUS) | 119 | login(ANONYMOUS) |
2870 | 120 | self.assertEqual(self.person.name, username) | 120 | self.assertEqual(self.person.name, username) |
2871 | @@ -306,7 +306,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2872 | 306 | 306 | ||
2873 | 307 | def test_createBranch_no_preceding_slash(self): | 307 | def test_createBranch_no_preceding_slash(self): |
2874 | 308 | requester = self.factory.makePerson() | 308 | requester = self.factory.makePerson() |
2876 | 309 | path = escape(u'invalid') | 309 | path = escape('invalid') |
2877 | 310 | fault = self.codehosting_api.createBranch(requester.id, path) | 310 | fault = self.codehosting_api.createBranch(requester.id, path) |
2878 | 311 | login(ANONYMOUS) | 311 | login(ANONYMOUS) |
2879 | 312 | self.assertEqual(faults.InvalidPath(path), fault) | 312 | self.assertEqual(faults.InvalidPath(path), fault) |
2880 | @@ -390,7 +390,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2881 | 390 | # Creating a branch with an invalid name fails. | 390 | # Creating a branch with an invalid name fails. |
2882 | 391 | owner = self.factory.makePerson() | 391 | owner = self.factory.makePerson() |
2883 | 392 | product = self.factory.makeProduct() | 392 | product = self.factory.makeProduct() |
2885 | 393 | invalid_name = u'invalid\N{LATIN SMALL LETTER E WITH ACUTE}' | 393 | invalid_name = 'invalid\N{LATIN SMALL LETTER E WITH ACUTE}' |
2886 | 394 | # LaunchpadValidationError unfortunately assumes its output is | 394 | # LaunchpadValidationError unfortunately assumes its output is |
2887 | 395 | # always HTML, so it ends up double-escaped in XML-RPC faults. | 395 | # always HTML, so it ends up double-escaped in XML-RPC faults. |
2888 | 396 | message = html_escape( | 396 | message = html_escape( |
2889 | @@ -526,8 +526,8 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2890 | 526 | owner = self.factory.makePerson() | 526 | owner = self.factory.makePerson() |
2891 | 527 | product = self.factory.makeProduct() | 527 | product = self.factory.makeProduct() |
2892 | 528 | branch_name = self.factory.getUniqueString('branch-name') | 528 | branch_name = self.factory.getUniqueString('branch-name') |
2895 | 529 | unique_name = u'~%s/%s/%s' % (owner.name, product.name, branch_name) | 529 | unique_name = '~%s/%s/%s' % (owner.name, product.name, branch_name) |
2896 | 530 | path = u'/%s/%s' % (BRANCH_ALIAS_PREFIX, unique_name) | 530 | path = '/%s/%s' % (BRANCH_ALIAS_PREFIX, unique_name) |
2897 | 531 | branch_id = self.codehosting_api.createBranch(owner.id, escape(path)) | 531 | branch_id = self.codehosting_api.createBranch(owner.id, escape(path)) |
2898 | 532 | login(ANONYMOUS) | 532 | login(ANONYMOUS) |
2899 | 533 | branch = self.branch_lookup.get(branch_id) | 533 | branch = self.branch_lookup.get(branch_id) |
2900 | @@ -539,8 +539,8 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2901 | 539 | owner = self.factory.makePerson() | 539 | owner = self.factory.makePerson() |
2902 | 540 | product = self.factory.makeProduct() | 540 | product = self.factory.makeProduct() |
2903 | 541 | branch_name = self.factory.getUniqueString('branch-name') | 541 | branch_name = self.factory.getUniqueString('branch-name') |
2906 | 542 | unique_name = u'~%s/%s/%s' % (owner.name, product.name, branch_name) | 542 | unique_name = '~%s/%s/%s' % (owner.name, product.name, branch_name) |
2907 | 543 | path = escape(u'/%s/%s' % (BRANCH_ALIAS_PREFIX, unique_name)) | 543 | path = escape('/%s/%s' % (BRANCH_ALIAS_PREFIX, unique_name)) |
2908 | 544 | branch_id = self.codehosting_api.createBranch(owner.id, path) | 544 | branch_id = self.codehosting_api.createBranch(owner.id, path) |
2909 | 545 | login(ANONYMOUS) | 545 | login(ANONYMOUS) |
2910 | 546 | translation = self.codehosting_api.translatePath(owner.id, path) | 546 | translation = self.codehosting_api.translatePath(owner.id, path) |
2911 | @@ -555,7 +555,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2912 | 555 | # it. | 555 | # it. |
2913 | 556 | owner = self.factory.makePerson() | 556 | owner = self.factory.makePerson() |
2914 | 557 | product = self.factory.makeProduct(owner=owner) | 557 | product = self.factory.makeProduct(owner=owner) |
2916 | 558 | path = u'/%s/%s' % (BRANCH_ALIAS_PREFIX, product.name) | 558 | path = '/%s/%s' % (BRANCH_ALIAS_PREFIX, product.name) |
2917 | 559 | branch_id = self.codehosting_api.createBranch(owner.id, escape(path)) | 559 | branch_id = self.codehosting_api.createBranch(owner.id, escape(path)) |
2918 | 560 | login(ANONYMOUS) | 560 | login(ANONYMOUS) |
2919 | 561 | branch = self.branch_lookup.get(branch_id) | 561 | branch = self.branch_lookup.get(branch_id) |
2920 | @@ -569,7 +569,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2921 | 569 | # immediately traversable using translatePath. | 569 | # immediately traversable using translatePath. |
2922 | 570 | product = self.factory.makeProduct() | 570 | product = self.factory.makeProduct() |
2923 | 571 | owner = product.owner | 571 | owner = product.owner |
2925 | 572 | path = escape(u'/%s/%s' % (BRANCH_ALIAS_PREFIX, product.name)) | 572 | path = escape('/%s/%s' % (BRANCH_ALIAS_PREFIX, product.name)) |
2926 | 573 | branch_id = self.codehosting_api.createBranch(owner.id, path) | 573 | branch_id = self.codehosting_api.createBranch(owner.id, path) |
2927 | 574 | login(ANONYMOUS) | 574 | login(ANONYMOUS) |
2928 | 575 | translation = self.codehosting_api.translatePath(owner.id, path) | 575 | translation = self.codehosting_api.translatePath(owner.id, path) |
2929 | @@ -583,7 +583,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2930 | 583 | # the new branch to the alias, then can't create the branch. | 583 | # the new branch to the alias, then can't create the branch. |
2931 | 584 | owner = self.factory.makePerson(name='eric') | 584 | owner = self.factory.makePerson(name='eric') |
2932 | 585 | product = self.factory.makeProduct('wibble') | 585 | product = self.factory.makeProduct('wibble') |
2934 | 586 | path = u'/%s/%s' % (BRANCH_ALIAS_PREFIX, product.name) | 586 | path = '/%s/%s' % (BRANCH_ALIAS_PREFIX, product.name) |
2935 | 587 | fault = self.codehosting_api.createBranch(owner.id, escape(path)) | 587 | fault = self.codehosting_api.createBranch(owner.id, escape(path)) |
2936 | 588 | message = "Cannot create linked branch at 'wibble'." | 588 | message = "Cannot create linked branch at 'wibble'." |
2937 | 589 | self.assertEqual(faults.PermissionDenied(message), fault) | 589 | self.assertEqual(faults.PermissionDenied(message), fault) |
2938 | @@ -595,7 +595,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2939 | 595 | def test_createBranch_using_branch_alias_product_not_exist(self): | 595 | def test_createBranch_using_branch_alias_product_not_exist(self): |
2940 | 596 | # If the product doesn't exist, we don't (yet) create one. | 596 | # If the product doesn't exist, we don't (yet) create one. |
2941 | 597 | owner = self.factory.makePerson() | 597 | owner = self.factory.makePerson() |
2943 | 598 | path = u'/%s/foible' % (BRANCH_ALIAS_PREFIX,) | 598 | path = '/%s/foible' % (BRANCH_ALIAS_PREFIX,) |
2944 | 599 | fault = self.codehosting_api.createBranch(owner.id, escape(path)) | 599 | fault = self.codehosting_api.createBranch(owner.id, escape(path)) |
2945 | 600 | message = "Project 'foible' does not exist." | 600 | message = "Project 'foible' does not exist." |
2946 | 601 | self.assertEqual(faults.NotFound(message), fault) | 601 | self.assertEqual(faults.NotFound(message), fault) |
2947 | @@ -607,7 +607,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2948 | 607 | owner = self.factory.makePerson() | 607 | owner = self.factory.makePerson() |
2949 | 608 | product = self.factory.makeProduct(owner=owner) | 608 | product = self.factory.makeProduct(owner=owner) |
2950 | 609 | series = self.factory.makeProductSeries(product=product) | 609 | series = self.factory.makeProductSeries(product=product) |
2952 | 610 | path = u'/%s/%s/%s' % (BRANCH_ALIAS_PREFIX, product.name, series.name) | 610 | path = '/%s/%s/%s' % (BRANCH_ALIAS_PREFIX, product.name, series.name) |
2953 | 611 | branch_id = self.codehosting_api.createBranch(owner.id, escape(path)) | 611 | branch_id = self.codehosting_api.createBranch(owner.id, escape(path)) |
2954 | 612 | login(ANONYMOUS) | 612 | login(ANONYMOUS) |
2955 | 613 | branch = self.branch_lookup.get(branch_id) | 613 | branch = self.branch_lookup.get(branch_id) |
2956 | @@ -622,7 +622,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2957 | 622 | owner = self.factory.makePerson() | 622 | owner = self.factory.makePerson() |
2958 | 623 | product = self.factory.makeProduct(name='wibble') | 623 | product = self.factory.makeProduct(name='wibble') |
2959 | 624 | self.factory.makeProductSeries(product=product, name='nip') | 624 | self.factory.makeProductSeries(product=product, name='nip') |
2961 | 625 | path = u'/%s/wibble/nip' % (BRANCH_ALIAS_PREFIX,) | 625 | path = '/%s/wibble/nip' % (BRANCH_ALIAS_PREFIX,) |
2962 | 626 | fault = self.codehosting_api.createBranch(owner.id, escape(path)) | 626 | fault = self.codehosting_api.createBranch(owner.id, escape(path)) |
2963 | 627 | message = "Cannot create linked branch at 'wibble/nip'." | 627 | message = "Cannot create linked branch at 'wibble/nip'." |
2964 | 628 | self.assertEqual(faults.PermissionDenied(message), fault) | 628 | self.assertEqual(faults.PermissionDenied(message), fault) |
2965 | @@ -631,7 +631,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2966 | 631 | # If the product series doesn't exist, we don't (yet) create it. | 631 | # If the product series doesn't exist, we don't (yet) create it. |
2967 | 632 | owner = self.factory.makePerson() | 632 | owner = self.factory.makePerson() |
2968 | 633 | self.factory.makeProduct(name='wibble') | 633 | self.factory.makeProduct(name='wibble') |
2970 | 634 | path = u'/%s/wibble/nip' % (BRANCH_ALIAS_PREFIX,) | 634 | path = '/%s/wibble/nip' % (BRANCH_ALIAS_PREFIX,) |
2971 | 635 | fault = self.codehosting_api.createBranch(owner.id, escape(path)) | 635 | fault = self.codehosting_api.createBranch(owner.id, escape(path)) |
2972 | 636 | message = "No such product series: 'nip'." | 636 | message = "No such product series: 'nip'." |
2973 | 637 | self.assertEqual(faults.NotFound(message), fault) | 637 | self.assertEqual(faults.NotFound(message), fault) |
2974 | @@ -777,19 +777,19 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2975 | 777 | # this happens, it returns a Fault saying so, including the path it | 777 | # this happens, it returns a Fault saying so, including the path it |
2976 | 778 | # couldn't translate. | 778 | # couldn't translate. |
2977 | 779 | requester = self.factory.makePerson() | 779 | requester = self.factory.makePerson() |
2979 | 780 | path = escape(u'/untranslatable') | 780 | path = escape('/untranslatable') |
2980 | 781 | self.assertNotFound(requester, path) | 781 | self.assertNotFound(requester, path) |
2981 | 782 | 782 | ||
2982 | 783 | def test_translatePath_no_preceding_slash(self): | 783 | def test_translatePath_no_preceding_slash(self): |
2983 | 784 | requester = self.factory.makePerson() | 784 | requester = self.factory.makePerson() |
2985 | 785 | path = escape(u'invalid') | 785 | path = escape('invalid') |
2986 | 786 | fault = self.codehosting_api.translatePath(requester.id, path) | 786 | fault = self.codehosting_api.translatePath(requester.id, path) |
2987 | 787 | self.assertEqual(faults.InvalidPath(path), fault) | 787 | self.assertEqual(faults.InvalidPath(path), fault) |
2988 | 788 | 788 | ||
2989 | 789 | def test_translatePath_branch(self): | 789 | def test_translatePath_branch(self): |
2990 | 790 | requester = self.factory.makePerson() | 790 | requester = self.factory.makePerson() |
2991 | 791 | branch = self.factory.makeAnyBranch() | 791 | branch = self.factory.makeAnyBranch() |
2993 | 792 | path = escape(u'/%s' % branch.unique_name) | 792 | path = escape('/%s' % branch.unique_name) |
2994 | 793 | translation = self.codehosting_api.translatePath(requester.id, path) | 793 | translation = self.codehosting_api.translatePath(requester.id, path) |
2995 | 794 | login(ANONYMOUS) | 794 | login(ANONYMOUS) |
2996 | 795 | self.assertEqual( | 795 | self.assertEqual( |
2997 | @@ -800,7 +800,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
2998 | 800 | def test_translatePath_branch_with_trailing_slash(self): | 800 | def test_translatePath_branch_with_trailing_slash(self): |
2999 | 801 | requester = self.factory.makePerson() | 801 | requester = self.factory.makePerson() |
3000 | 802 | branch = self.factory.makeAnyBranch() | 802 | branch = self.factory.makeAnyBranch() |
3002 | 803 | path = escape(u'/%s/' % branch.unique_name) | 803 | path = escape('/%s/' % branch.unique_name) |
3003 | 804 | translation = self.codehosting_api.translatePath(requester.id, path) | 804 | translation = self.codehosting_api.translatePath(requester.id, path) |
3004 | 805 | login(ANONYMOUS) | 805 | login(ANONYMOUS) |
3005 | 806 | self.assertEqual( | 806 | self.assertEqual( |
3006 | @@ -811,7 +811,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3007 | 811 | def test_translatePath_path_in_branch(self): | 811 | def test_translatePath_path_in_branch(self): |
3008 | 812 | requester = self.factory.makePerson() | 812 | requester = self.factory.makePerson() |
3009 | 813 | branch = self.factory.makeAnyBranch() | 813 | branch = self.factory.makeAnyBranch() |
3011 | 814 | path = escape(u'/%s/child' % branch.unique_name) | 814 | path = escape('/%s/child' % branch.unique_name) |
3012 | 815 | translation = self.codehosting_api.translatePath(requester.id, path) | 815 | translation = self.codehosting_api.translatePath(requester.id, path) |
3013 | 816 | login(ANONYMOUS) | 816 | login(ANONYMOUS) |
3014 | 817 | self.assertEqual( | 817 | self.assertEqual( |
3015 | @@ -822,7 +822,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3016 | 822 | def test_translatePath_nested_path_in_branch(self): | 822 | def test_translatePath_nested_path_in_branch(self): |
3017 | 823 | requester = self.factory.makePerson() | 823 | requester = self.factory.makePerson() |
3018 | 824 | branch = self.factory.makeAnyBranch() | 824 | branch = self.factory.makeAnyBranch() |
3020 | 825 | path = escape(u'/%s/a/b' % branch.unique_name) | 825 | path = escape('/%s/a/b' % branch.unique_name) |
3021 | 826 | translation = self.codehosting_api.translatePath(requester.id, path) | 826 | translation = self.codehosting_api.translatePath(requester.id, path) |
3022 | 827 | login(ANONYMOUS) | 827 | login(ANONYMOUS) |
3023 | 828 | self.assertEqual( | 828 | self.assertEqual( |
3024 | @@ -833,11 +833,11 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3025 | 833 | def test_translatePath_preserves_escaping(self): | 833 | def test_translatePath_preserves_escaping(self): |
3026 | 834 | requester = self.factory.makePerson() | 834 | requester = self.factory.makePerson() |
3027 | 835 | branch = self.factory.makeAnyBranch() | 835 | branch = self.factory.makeAnyBranch() |
3029 | 836 | child_path = u'a@b' | 836 | child_path = 'a@b' |
3030 | 837 | # This test is only meaningful if the path isn't the same when | 837 | # This test is only meaningful if the path isn't the same when |
3031 | 838 | # escaped. | 838 | # escaped. |
3032 | 839 | self.assertNotEqual(escape(child_path), child_path.encode('utf-8')) | 839 | self.assertNotEqual(escape(child_path), child_path.encode('utf-8')) |
3034 | 840 | path = escape(u'/%s/%s' % (branch.unique_name, child_path)) | 840 | path = escape('/%s/%s' % (branch.unique_name, child_path)) |
3035 | 841 | translation = self.codehosting_api.translatePath(requester.id, path) | 841 | translation = self.codehosting_api.translatePath(requester.id, path) |
3036 | 842 | login(ANONYMOUS) | 842 | login(ANONYMOUS) |
3037 | 843 | self.assertEqual( | 843 | self.assertEqual( |
3038 | @@ -886,7 +886,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3039 | 886 | def test_translatePath_no_such_branch_non_ascii(self): | 886 | def test_translatePath_no_such_branch_non_ascii(self): |
3040 | 887 | requester = self.factory.makePerson() | 887 | requester = self.factory.makePerson() |
3041 | 888 | product = self.factory.makeProduct() | 888 | product = self.factory.makeProduct() |
3043 | 889 | path = u'/~%s/%s/non-asci\N{LATIN SMALL LETTER I WITH DIAERESIS}' % ( | 889 | path = '/~%s/%s/non-asci\N{LATIN SMALL LETTER I WITH DIAERESIS}' % ( |
3044 | 890 | requester.name, product.name) | 890 | requester.name, product.name) |
3045 | 891 | self.assertNotFound(requester, escape(path)) | 891 | self.assertNotFound(requester, escape(path)) |
3046 | 892 | 892 | ||
3047 | @@ -896,7 +896,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3048 | 896 | self.factory.makeAnyBranch( | 896 | self.factory.makeAnyBranch( |
3049 | 897 | branch_type=BranchType.HOSTED, owner=requester, | 897 | branch_type=BranchType.HOSTED, owner=requester, |
3050 | 898 | information_type=InformationType.USERDATA)) | 898 | information_type=InformationType.USERDATA)) |
3052 | 899 | path = escape(u'/%s' % branch.unique_name) | 899 | path = escape('/%s' % branch.unique_name) |
3053 | 900 | translation = self.codehosting_api.translatePath(requester.id, path) | 900 | translation = self.codehosting_api.translatePath(requester.id, path) |
3054 | 901 | login(ANONYMOUS) | 901 | login(ANONYMOUS) |
3055 | 902 | self.assertEqual( | 902 | self.assertEqual( |
3056 | @@ -908,19 +908,19 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3057 | 908 | requester = self.factory.makePerson() | 908 | requester = self.factory.makePerson() |
3058 | 909 | branch = removeSecurityProxy(self.factory.makeAnyBranch( | 909 | branch = removeSecurityProxy(self.factory.makeAnyBranch( |
3059 | 910 | information_type=InformationType.USERDATA)) | 910 | information_type=InformationType.USERDATA)) |
3061 | 911 | path = escape(u'/%s' % branch.unique_name) | 911 | path = escape('/%s' % branch.unique_name) |
3062 | 912 | self.assertPermissionDenied(requester, path) | 912 | self.assertPermissionDenied(requester, path) |
3063 | 913 | 913 | ||
3064 | 914 | def test_translatePath_remote_branch(self): | 914 | def test_translatePath_remote_branch(self): |
3065 | 915 | requester = self.factory.makePerson() | 915 | requester = self.factory.makePerson() |
3066 | 916 | branch = self.factory.makeAnyBranch(branch_type=BranchType.REMOTE) | 916 | branch = self.factory.makeAnyBranch(branch_type=BranchType.REMOTE) |
3068 | 917 | path = escape(u'/%s' % branch.unique_name) | 917 | path = escape('/%s' % branch.unique_name) |
3069 | 918 | self.assertNotFound(requester, path) | 918 | self.assertNotFound(requester, path) |
3070 | 919 | 919 | ||
3071 | 920 | def test_translatePath_launchpad_services_private(self): | 920 | def test_translatePath_launchpad_services_private(self): |
3072 | 921 | branch = removeSecurityProxy(self.factory.makeAnyBranch( | 921 | branch = removeSecurityProxy(self.factory.makeAnyBranch( |
3073 | 922 | information_type=InformationType.USERDATA)) | 922 | information_type=InformationType.USERDATA)) |
3075 | 923 | path = escape(u'/%s' % branch.unique_name) | 923 | path = escape('/%s' % branch.unique_name) |
3076 | 924 | translation = self.codehosting_api.translatePath( | 924 | translation = self.codehosting_api.translatePath( |
3077 | 925 | LAUNCHPAD_SERVICES, path) | 925 | LAUNCHPAD_SERVICES, path) |
3078 | 926 | login(ANONYMOUS) | 926 | login(ANONYMOUS) |
3079 | @@ -932,12 +932,12 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3080 | 932 | def test_translatePath_anonymous_cant_see_private_branch(self): | 932 | def test_translatePath_anonymous_cant_see_private_branch(self): |
3081 | 933 | branch = removeSecurityProxy(self.factory.makeAnyBranch( | 933 | branch = removeSecurityProxy(self.factory.makeAnyBranch( |
3082 | 934 | information_type=InformationType.USERDATA)) | 934 | information_type=InformationType.USERDATA)) |
3084 | 935 | path = escape(u'/%s' % branch.unique_name) | 935 | path = escape('/%s' % branch.unique_name) |
3085 | 936 | self.assertPermissionDenied(LAUNCHPAD_ANONYMOUS, path) | 936 | self.assertPermissionDenied(LAUNCHPAD_ANONYMOUS, path) |
3086 | 937 | 937 | ||
3087 | 938 | def test_translatePath_anonymous_public_branch(self): | 938 | def test_translatePath_anonymous_public_branch(self): |
3088 | 939 | branch = self.factory.makeAnyBranch() | 939 | branch = self.factory.makeAnyBranch() |
3090 | 940 | path = escape(u'/%s' % branch.unique_name) | 940 | path = escape('/%s' % branch.unique_name) |
3091 | 941 | translation = self.codehosting_api.translatePath( | 941 | translation = self.codehosting_api.translatePath( |
3092 | 942 | LAUNCHPAD_ANONYMOUS, path) | 942 | LAUNCHPAD_ANONYMOUS, path) |
3093 | 943 | self.assertEqual( | 943 | self.assertEqual( |
3094 | @@ -949,7 +949,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3095 | 949 | requester = self.factory.makePerson() | 949 | requester = self.factory.makePerson() |
3096 | 950 | branch = self.factory.makeAnyBranch( | 950 | branch = self.factory.makeAnyBranch( |
3097 | 951 | branch_type=BranchType.HOSTED, owner=requester) | 951 | branch_type=BranchType.HOSTED, owner=requester) |
3099 | 952 | path = escape(u'/%s' % branch.unique_name) | 952 | path = escape('/%s' % branch.unique_name) |
3100 | 953 | translation = self.codehosting_api.translatePath(requester.id, path) | 953 | translation = self.codehosting_api.translatePath(requester.id, path) |
3101 | 954 | login(ANONYMOUS) | 954 | login(ANONYMOUS) |
3102 | 955 | self.assertEqual( | 955 | self.assertEqual( |
3103 | @@ -962,7 +962,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3104 | 962 | team = self.factory.makeTeam(requester) | 962 | team = self.factory.makeTeam(requester) |
3105 | 963 | branch = self.factory.makeAnyBranch( | 963 | branch = self.factory.makeAnyBranch( |
3106 | 964 | branch_type=BranchType.HOSTED, owner=team) | 964 | branch_type=BranchType.HOSTED, owner=team) |
3108 | 965 | path = escape(u'/%s' % branch.unique_name) | 965 | path = escape('/%s' % branch.unique_name) |
3109 | 966 | translation = self.codehosting_api.translatePath(requester.id, path) | 966 | translation = self.codehosting_api.translatePath(requester.id, path) |
3110 | 967 | login(ANONYMOUS) | 967 | login(ANONYMOUS) |
3111 | 968 | self.assertEqual( | 968 | self.assertEqual( |
3112 | @@ -975,7 +975,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3113 | 975 | team = self.factory.makeTeam(self.factory.makePerson()) | 975 | team = self.factory.makeTeam(self.factory.makePerson()) |
3114 | 976 | branch = self.factory.makeAnyBranch( | 976 | branch = self.factory.makeAnyBranch( |
3115 | 977 | branch_type=BranchType.HOSTED, owner=team) | 977 | branch_type=BranchType.HOSTED, owner=team) |
3117 | 978 | path = escape(u'/%s' % branch.unique_name) | 978 | path = escape('/%s' % branch.unique_name) |
3118 | 979 | translation = self.codehosting_api.translatePath(requester.id, path) | 979 | translation = self.codehosting_api.translatePath(requester.id, path) |
3119 | 980 | login(ANONYMOUS) | 980 | login(ANONYMOUS) |
3120 | 981 | self.assertEqual( | 981 | self.assertEqual( |
3121 | @@ -987,7 +987,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3122 | 987 | requester = self.factory.makePerson() | 987 | requester = self.factory.makePerson() |
3123 | 988 | branch = self.factory.makeAnyBranch( | 988 | branch = self.factory.makeAnyBranch( |
3124 | 989 | branch_type=BranchType.MIRRORED, owner=requester) | 989 | branch_type=BranchType.MIRRORED, owner=requester) |
3126 | 990 | path = escape(u'/%s' % branch.unique_name) | 990 | path = escape('/%s' % branch.unique_name) |
3127 | 991 | translation = self.codehosting_api.translatePath(requester.id, path) | 991 | translation = self.codehosting_api.translatePath(requester.id, path) |
3128 | 992 | login(ANONYMOUS) | 992 | login(ANONYMOUS) |
3129 | 993 | self.assertEqual( | 993 | self.assertEqual( |
3130 | @@ -999,7 +999,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3131 | 999 | requester = self.factory.makePerson() | 999 | requester = self.factory.makePerson() |
3132 | 1000 | branch = self.factory.makeAnyBranch( | 1000 | branch = self.factory.makeAnyBranch( |
3133 | 1001 | branch_type=BranchType.IMPORTED, owner=requester) | 1001 | branch_type=BranchType.IMPORTED, owner=requester) |
3135 | 1002 | path = escape(u'/%s' % branch.unique_name) | 1002 | path = escape('/%s' % branch.unique_name) |
3136 | 1003 | translation = self.codehosting_api.translatePath(requester.id, path) | 1003 | translation = self.codehosting_api.translatePath(requester.id, path) |
3137 | 1004 | login(ANONYMOUS) | 1004 | login(ANONYMOUS) |
3138 | 1005 | self.assertEqual( | 1005 | self.assertEqual( |
3139 | @@ -1015,7 +1015,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3140 | 1015 | removeSecurityProxy(branch.product.development_focus).branch = branch | 1015 | removeSecurityProxy(branch.product.development_focus).branch = branch |
3141 | 1016 | short_name = ICanHasLinkedBranch(branch.product).bzr_path | 1016 | short_name = ICanHasLinkedBranch(branch.product).bzr_path |
3142 | 1017 | path_in_branch = '.bzr/branch-format' | 1017 | path_in_branch = '.bzr/branch-format' |
3144 | 1018 | path = escape(u'/%s' % os.path.join( | 1018 | path = escape('/%s' % os.path.join( |
3145 | 1019 | BRANCH_ALIAS_PREFIX, short_name, path_in_branch)) | 1019 | BRANCH_ALIAS_PREFIX, short_name, path_in_branch)) |
3146 | 1020 | translation = self.codehosting_api.translatePath(requester.id, path) | 1020 | translation = self.codehosting_api.translatePath(requester.id, path) |
3147 | 1021 | login(ANONYMOUS) | 1021 | login(ANONYMOUS) |
3148 | @@ -1030,7 +1030,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3149 | 1030 | requester = self.factory.makePerson() | 1030 | requester = self.factory.makePerson() |
3150 | 1031 | branch = self.factory.makeBranch() | 1031 | branch = self.factory.makeBranch() |
3151 | 1032 | path_in_branch = '.bzr/branch-format' | 1032 | path_in_branch = '.bzr/branch-format' |
3153 | 1033 | path = escape(u'/%s' % os.path.join( | 1033 | path = escape('/%s' % os.path.join( |
3154 | 1034 | BRANCH_ALIAS_PREFIX, branch.unique_name, path_in_branch)) | 1034 | BRANCH_ALIAS_PREFIX, branch.unique_name, path_in_branch)) |
3155 | 1035 | translation = self.codehosting_api.translatePath(requester.id, path) | 1035 | translation = self.codehosting_api.translatePath(requester.id, path) |
3156 | 1036 | login(ANONYMOUS) | 1036 | login(ANONYMOUS) |
3157 | @@ -1147,7 +1147,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3158 | 1147 | # Make sure the trailing path is returned. | 1147 | # Make sure the trailing path is returned. |
3159 | 1148 | requester = self.factory.makePerson() | 1148 | requester = self.factory.makePerson() |
3160 | 1149 | branch = removeSecurityProxy(self.factory.makeAnyBranch()) | 1149 | branch = removeSecurityProxy(self.factory.makeAnyBranch()) |
3162 | 1150 | path = escape(u'%s/foo/bar' % branch_id_alias(branch)) | 1150 | path = escape('%s/foo/bar' % branch_id_alias(branch)) |
3163 | 1151 | translation = self.codehosting_api.translatePath(requester.id, path) | 1151 | translation = self.codehosting_api.translatePath(requester.id, path) |
3164 | 1152 | expected = ( | 1152 | expected = ( |
3165 | 1153 | BRANCH_TRANSPORT, | 1153 | BRANCH_TRANSPORT, |
3166 | @@ -1206,7 +1206,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3167 | 1206 | def test_translatePath_control_directory(self): | 1206 | def test_translatePath_control_directory(self): |
3168 | 1207 | requester = self.factory.makePerson() | 1207 | requester = self.factory.makePerson() |
3169 | 1208 | product, branch = self._makeProductWithDevFocus() | 1208 | product, branch = self._makeProductWithDevFocus() |
3171 | 1209 | path = escape(u'/~%s/%s/.bzr' % (requester.name, product.name)) | 1209 | path = escape('/~%s/%s/.bzr' % (requester.name, product.name)) |
3172 | 1210 | translation = self.codehosting_api.translatePath(requester.id, path) | 1210 | translation = self.codehosting_api.translatePath(requester.id, path) |
3173 | 1211 | login(ANONYMOUS) | 1211 | login(ANONYMOUS) |
3174 | 1212 | self.assertTranslationIsControlDirectory( | 1212 | self.assertTranslationIsControlDirectory( |
3175 | @@ -1219,20 +1219,20 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3176 | 1219 | # don't even bother translating control directory paths. | 1219 | # don't even bother translating control directory paths. |
3177 | 1220 | requester = self.factory.makePerson() | 1220 | requester = self.factory.makePerson() |
3178 | 1221 | product = self.factory.makeProduct() | 1221 | product = self.factory.makeProduct() |
3180 | 1222 | path = escape(u'/~%s/%s/.bzr/' % (requester.name, product.name)) | 1222 | path = escape('/~%s/%s/.bzr/' % (requester.name, product.name)) |
3181 | 1223 | self.assertNotFound(requester, path) | 1223 | self.assertNotFound(requester, path) |
3182 | 1224 | 1224 | ||
3183 | 1225 | def test_translatePath_control_directory_invisble_branch(self): | 1225 | def test_translatePath_control_directory_invisble_branch(self): |
3184 | 1226 | requester = self.factory.makePerson() | 1226 | requester = self.factory.makePerson() |
3185 | 1227 | product, branch = self._makeProductWithDevFocus(private=True) | 1227 | product, branch = self._makeProductWithDevFocus(private=True) |
3187 | 1228 | path = escape(u'/~%s/%s/.bzr/' % (requester.name, product.name)) | 1228 | path = escape('/~%s/%s/.bzr/' % (requester.name, product.name)) |
3188 | 1229 | self.assertNotFound(requester, path) | 1229 | self.assertNotFound(requester, path) |
3189 | 1230 | 1230 | ||
3190 | 1231 | def test_translatePath_control_directory_private_branch(self): | 1231 | def test_translatePath_control_directory_private_branch(self): |
3191 | 1232 | product, branch = self._makeProductWithDevFocus(private=True) | 1232 | product, branch = self._makeProductWithDevFocus(private=True) |
3192 | 1233 | branch = removeSecurityProxy(branch) | 1233 | branch = removeSecurityProxy(branch) |
3193 | 1234 | requester = branch.owner | 1234 | requester = branch.owner |
3195 | 1235 | path = escape(u'/~%s/%s/.bzr/' % (requester.name, product.name)) | 1235 | path = escape('/~%s/%s/.bzr/' % (requester.name, product.name)) |
3196 | 1236 | translation = self.codehosting_api.translatePath(requester.id, path) | 1236 | translation = self.codehosting_api.translatePath(requester.id, path) |
3197 | 1237 | login(ANONYMOUS) | 1237 | login(ANONYMOUS) |
3198 | 1238 | self.assertTranslationIsControlDirectory( | 1238 | self.assertTranslationIsControlDirectory( |
3199 | @@ -1244,7 +1244,7 @@ class CodehostingTest(WithScenarios, TestCaseWithFactory): | |||
3200 | 1244 | requester = self.factory.makePerson() | 1244 | requester = self.factory.makePerson() |
3201 | 1245 | product, branch = self._makeProductWithDevFocus() | 1245 | product, branch = self._makeProductWithDevFocus() |
3202 | 1246 | owner = self.factory.makePerson() | 1246 | owner = self.factory.makePerson() |
3204 | 1247 | path = escape(u'/~%s/%s/.bzr' % (owner.name, product.name)) | 1247 | path = escape('/~%s/%s/.bzr' % (owner.name, product.name)) |
3205 | 1248 | translation = self.codehosting_api.translatePath(requester.id, path) | 1248 | translation = self.codehosting_api.translatePath(requester.id, path) |
3206 | 1249 | login(ANONYMOUS) | 1249 | login(ANONYMOUS) |
3207 | 1250 | self.assertTranslationIsControlDirectory( | 1250 | self.assertTranslationIsControlDirectory( |
3208 | @@ -1291,7 +1291,7 @@ class AcquireBranchToPullTestsViaEndpoint(WithScenarios, TestCaseWithFactory, | |||
3209 | 1291 | ] | 1291 | ] |
3210 | 1292 | 1292 | ||
3211 | 1293 | def setUp(self): | 1293 | def setUp(self): |
3213 | 1294 | super(AcquireBranchToPullTestsViaEndpoint, self).setUp() | 1294 | super().setUp() |
3214 | 1295 | frontend = self.frontend() | 1295 | frontend = self.frontend() |
3215 | 1296 | self.codehosting_api = frontend.getCodehostingEndpoint() | 1296 | self.codehosting_api = frontend.getCodehostingEndpoint() |
3216 | 1297 | self.factory = frontend.getLaunchpadObjectFactory() | 1297 | self.factory = frontend.getLaunchpadObjectFactory() |
3217 | diff --git a/lib/lp/code/xmlrpc/tests/test_git.py b/lib/lp/code/xmlrpc/tests/test_git.py | |||
3218 | index 27c78c4..9dd57c1 100644 | |||
3219 | --- a/lib/lp/code/xmlrpc/tests/test_git.py | |||
3220 | +++ b/lib/lp/code/xmlrpc/tests/test_git.py | |||
3221 | @@ -138,7 +138,7 @@ class MatchesFault(MatchesStructure): | |||
3222 | 138 | 138 | ||
3223 | 139 | def __init__(self, expected_fault): | 139 | def __init__(self, expected_fault): |
3224 | 140 | fault_matchers = {} | 140 | fault_matchers = {} |
3226 | 141 | if (isinstance(expected_fault, six.class_types) and | 141 | if (isinstance(expected_fault, type) and |
3227 | 142 | issubclass(expected_fault, faults.LaunchpadFault)): | 142 | issubclass(expected_fault, faults.LaunchpadFault)): |
3228 | 143 | fault_matchers["faultCode"] = Equals(expected_fault.error_code) | 143 | fault_matchers["faultCode"] = Equals(expected_fault.error_code) |
3229 | 144 | else: | 144 | else: |
3230 | @@ -146,17 +146,17 @@ class MatchesFault(MatchesStructure): | |||
3231 | 146 | fault_string = expected_fault.faultString | 146 | fault_string = expected_fault.faultString |
3232 | 147 | # XXX cjwatson 2019-09-27: InvalidBranchName.faultString is | 147 | # XXX cjwatson 2019-09-27: InvalidBranchName.faultString is |
3233 | 148 | # bytes, so we need this to handle that case. Should it be? | 148 | # bytes, so we need this to handle that case. Should it be? |
3235 | 149 | if not isinstance(fault_string, six.text_type): | 149 | if not isinstance(fault_string, str): |
3236 | 150 | fault_string = fault_string.decode("UTF-8") | 150 | fault_string = fault_string.decode("UTF-8") |
3237 | 151 | fault_matchers["faultString"] = Equals(fault_string) | 151 | fault_matchers["faultString"] = Equals(fault_string) |
3239 | 152 | super(MatchesFault, self).__init__(**fault_matchers) | 152 | super().__init__(**fault_matchers) |
3240 | 153 | 153 | ||
3241 | 154 | 154 | ||
3242 | 155 | class TestGitAPIMixin: | 155 | class TestGitAPIMixin: |
3243 | 156 | """Helper methods for `IGitAPI` tests, and security-relevant tests.""" | 156 | """Helper methods for `IGitAPI` tests, and security-relevant tests.""" |
3244 | 157 | 157 | ||
3245 | 158 | def setUp(self): | 158 | def setUp(self): |
3247 | 159 | super(TestGitAPIMixin, self).setUp() | 159 | super().setUp() |
3248 | 160 | self.git_api = xmlrpc.client.ServerProxy( | 160 | self.git_api = xmlrpc.client.ServerProxy( |
3249 | 161 | "http://xmlrpc-private.launchpad.test:8087/git", | 161 | "http://xmlrpc-private.launchpad.test:8087/git", |
3250 | 162 | transport=XMLRPCTestTransport()) | 162 | transport=XMLRPCTestTransport()) |
3251 | @@ -495,7 +495,7 @@ class TestGitAPIMixin: | |||
3252 | 495 | repository = removeSecurityProxy( | 495 | repository = removeSecurityProxy( |
3253 | 496 | self.factory.makeGitRepository( | 496 | self.factory.makeGitRepository( |
3254 | 497 | owner=requester, information_type=InformationType.USERDATA)) | 497 | owner=requester, information_type=InformationType.USERDATA)) |
3256 | 498 | path = u"/%s" % repository.unique_name | 498 | path = "/%s" % repository.unique_name |
3257 | 499 | self.assertTranslates(requester, path, repository, True, private=True) | 499 | self.assertTranslates(requester, path, repository, True, private=True) |
3258 | 500 | 500 | ||
3259 | 501 | def test_translatePath_cannot_see_private_repository(self): | 501 | def test_translatePath_cannot_see_private_repository(self): |
3260 | @@ -503,14 +503,14 @@ class TestGitAPIMixin: | |||
3261 | 503 | repository = removeSecurityProxy( | 503 | repository = removeSecurityProxy( |
3262 | 504 | self.factory.makeGitRepository( | 504 | self.factory.makeGitRepository( |
3263 | 505 | information_type=InformationType.USERDATA)) | 505 | information_type=InformationType.USERDATA)) |
3265 | 506 | path = u"/%s" % repository.unique_name | 506 | path = "/%s" % repository.unique_name |
3266 | 507 | self.assertGitRepositoryNotFound(requester, path) | 507 | self.assertGitRepositoryNotFound(requester, path) |
3267 | 508 | 508 | ||
3268 | 509 | def test_translatePath_anonymous_cannot_see_private_repository(self): | 509 | def test_translatePath_anonymous_cannot_see_private_repository(self): |
3269 | 510 | repository = removeSecurityProxy( | 510 | repository = removeSecurityProxy( |
3270 | 511 | self.factory.makeGitRepository( | 511 | self.factory.makeGitRepository( |
3271 | 512 | information_type=InformationType.USERDATA)) | 512 | information_type=InformationType.USERDATA)) |
3273 | 513 | path = u"/%s" % repository.unique_name | 513 | path = "/%s" % repository.unique_name |
3274 | 514 | self.assertGitRepositoryNotFound(None, path, can_authenticate=False) | 514 | self.assertGitRepositoryNotFound(None, path, can_authenticate=False) |
3275 | 515 | self.assertUnauthorized(None, path, can_authenticate=True) | 515 | self.assertUnauthorized(None, path, can_authenticate=True) |
3276 | 516 | 516 | ||
3277 | @@ -518,7 +518,7 @@ class TestGitAPIMixin: | |||
3278 | 518 | requester = self.factory.makePerson() | 518 | requester = self.factory.makePerson() |
3279 | 519 | team = self.factory.makeTeam(self.factory.makePerson()) | 519 | team = self.factory.makeTeam(self.factory.makePerson()) |
3280 | 520 | repository = self.factory.makeGitRepository(owner=team) | 520 | repository = self.factory.makeGitRepository(owner=team) |
3282 | 521 | path = u"/%s" % repository.unique_name | 521 | path = "/%s" % repository.unique_name |
3283 | 522 | self.assertTranslates(requester, path, repository, False) | 522 | self.assertTranslates(requester, path, repository, False) |
3284 | 523 | self.assertPermissionDenied(requester, path, permission="write") | 523 | self.assertPermissionDenied(requester, path, permission="write") |
3285 | 524 | 524 | ||
3286 | @@ -526,7 +526,7 @@ class TestGitAPIMixin: | |||
3287 | 526 | requester = self.factory.makePerson() | 526 | requester = self.factory.makePerson() |
3288 | 527 | repository = self.factory.makeGitRepository( | 527 | repository = self.factory.makeGitRepository( |
3289 | 528 | owner=requester, repository_type=GitRepositoryType.IMPORTED) | 528 | owner=requester, repository_type=GitRepositoryType.IMPORTED) |
3291 | 529 | path = u"/%s" % repository.unique_name | 529 | path = "/%s" % repository.unique_name |
3292 | 530 | self.assertTranslates(requester, path, repository, False) | 530 | self.assertTranslates(requester, path, repository, False) |
3293 | 531 | self.assertPermissionDenied(requester, path, permission="write") | 531 | self.assertPermissionDenied(requester, path, permission="write") |
3294 | 532 | 532 | ||
3295 | @@ -538,7 +538,7 @@ class TestGitAPIMixin: | |||
3296 | 538 | message = "%s is not a member of %s" % ( | 538 | message = "%s is not a member of %s" % ( |
3297 | 539 | requester.displayname, team.displayname) | 539 | requester.displayname, team.displayname) |
3298 | 540 | self.assertPermissionDenied( | 540 | self.assertPermissionDenied( |
3300 | 541 | requester, u"/~%s/+git/random" % team.name, message=message, | 541 | requester, "/~%s/+git/random" % team.name, message=message, |
3301 | 542 | permission="write") | 542 | permission="write") |
3302 | 543 | 543 | ||
3303 | 544 | def test_translatePath_create_other_user(self): | 544 | def test_translatePath_create_other_user(self): |
3304 | @@ -547,7 +547,7 @@ class TestGitAPIMixin: | |||
3305 | 547 | other_person = self.factory.makePerson() | 547 | other_person = self.factory.makePerson() |
3306 | 548 | project = self.factory.makeProduct() | 548 | project = self.factory.makeProduct() |
3307 | 549 | name = self.factory.getUniqueString() | 549 | name = self.factory.getUniqueString() |
3309 | 550 | path = u"/~%s/%s/+git/%s" % (other_person.name, project.name, name) | 550 | path = "/~%s/%s/+git/%s" % (other_person.name, project.name, name) |
3310 | 551 | message = "%s cannot create Git repositories owned by %s" % ( | 551 | message = "%s cannot create Git repositories owned by %s" % ( |
3311 | 552 | requester.displayname, other_person.displayname) | 552 | requester.displayname, other_person.displayname) |
3312 | 553 | self.assertPermissionDenied( | 553 | self.assertPermissionDenied( |
3313 | @@ -558,7 +558,7 @@ class TestGitAPIMixin: | |||
3314 | 558 | # repository and immediately set it as the default for that project. | 558 | # repository and immediately set it as the default for that project. |
3315 | 559 | requester = self.factory.makePerson() | 559 | requester = self.factory.makePerson() |
3316 | 560 | project = self.factory.makeProduct() | 560 | project = self.factory.makeProduct() |
3318 | 561 | path = u"/%s" % project.name | 561 | path = "/%s" % project.name |
3319 | 562 | message = "%s cannot create Git repositories owned by %s" % ( | 562 | message = "%s cannot create Git repositories owned by %s" % ( |
3320 | 563 | requester.displayname, project.owner.displayname) | 563 | requester.displayname, project.owner.displayname) |
3321 | 564 | initial_count = getUtility(IAllGitRepositories).count() | 564 | initial_count = getUtility(IAllGitRepositories).count() |
3322 | @@ -577,7 +577,7 @@ class TestGitAPIMixin: | |||
3323 | 577 | distribution = self.factory.makeDistribution( | 577 | distribution = self.factory.makeDistribution( |
3324 | 578 | oci_project_admin=self.factory.makeTeam()) | 578 | oci_project_admin=self.factory.makeTeam()) |
3325 | 579 | oci_project = self.factory.makeOCIProject(pillar=distribution) | 579 | oci_project = self.factory.makeOCIProject(pillar=distribution) |
3327 | 580 | path = u"/%s/+oci/%s" % (oci_project.pillar.name, oci_project.name) | 580 | path = "/%s/+oci/%s" % (oci_project.pillar.name, oci_project.name) |
3328 | 581 | message = "%s is not a member of %s" % ( | 581 | message = "%s is not a member of %s" % ( |
3329 | 582 | requester.displayname, | 582 | requester.displayname, |
3330 | 583 | oci_project.pillar.oci_project_admin.displayname) | 583 | oci_project.pillar.oci_project_admin.displayname) |
3331 | @@ -594,11 +594,11 @@ class TestGitAPIMixin: | |||
3332 | 594 | other_person = self.factory.makePerson() | 594 | other_person = self.factory.makePerson() |
3333 | 595 | repository = self.factory.makeGitRepository(owner=requester) | 595 | repository = self.factory.makeGitRepository(owner=requester) |
3334 | 596 | rule = self.factory.makeGitRule( | 596 | rule = self.factory.makeGitRule( |
3336 | 597 | repository, ref_pattern=u'refs/heads/stable/next') | 597 | repository, ref_pattern='refs/heads/stable/next') |
3337 | 598 | self.factory.makeGitRuleGrant( | 598 | self.factory.makeGitRuleGrant( |
3338 | 599 | rule=rule, grantee=other_person, | 599 | rule=rule, grantee=other_person, |
3339 | 600 | can_force_push=True) | 600 | can_force_push=True) |
3341 | 601 | path = u"/%s" % repository.unique_name | 601 | path = "/%s" % repository.unique_name |
3342 | 602 | self.assertTranslates( | 602 | self.assertTranslates( |
3343 | 603 | other_person, path, repository, True, private=False) | 603 | other_person, path, repository, True, private=False) |
3344 | 604 | 604 | ||
3345 | @@ -608,11 +608,11 @@ class TestGitAPIMixin: | |||
3346 | 608 | other_person = self.factory.makePerson() | 608 | other_person = self.factory.makePerson() |
3347 | 609 | repository = self.factory.makeGitRepository(owner=requester) | 609 | repository = self.factory.makeGitRepository(owner=requester) |
3348 | 610 | rule = self.factory.makeGitRule( | 610 | rule = self.factory.makeGitRule( |
3350 | 611 | repository, ref_pattern=u'refs/heads/stable/next') | 611 | repository, ref_pattern='refs/heads/stable/next') |
3351 | 612 | self.factory.makeGitRuleGrant( | 612 | self.factory.makeGitRuleGrant( |
3352 | 613 | rule=rule, grantee=grant_person, | 613 | rule=rule, grantee=grant_person, |
3353 | 614 | can_force_push=True) | 614 | can_force_push=True) |
3355 | 615 | path = u"/%s" % repository.unique_name | 615 | path = "/%s" % repository.unique_name |
3356 | 616 | self.assertTranslates( | 616 | self.assertTranslates( |
3357 | 617 | other_person, path, repository, False, private=False) | 617 | other_person, path, repository, False, private=False) |
3358 | 618 | 618 | ||
3359 | @@ -623,11 +623,11 @@ class TestGitAPIMixin: | |||
3360 | 623 | self.factory.makeGitRepository( | 623 | self.factory.makeGitRepository( |
3361 | 624 | owner=requester, information_type=InformationType.USERDATA)) | 624 | owner=requester, information_type=InformationType.USERDATA)) |
3362 | 625 | rule = self.factory.makeGitRule( | 625 | rule = self.factory.makeGitRule( |
3364 | 626 | repository, ref_pattern=u'refs/heads/stable/next') | 626 | repository, ref_pattern='refs/heads/stable/next') |
3365 | 627 | self.factory.makeGitRuleGrant( | 627 | self.factory.makeGitRuleGrant( |
3366 | 628 | rule=rule, grantee=other_person, | 628 | rule=rule, grantee=other_person, |
3367 | 629 | can_force_push=True) | 629 | can_force_push=True) |
3369 | 630 | path = u"/%s" % repository.unique_name | 630 | path = "/%s" % repository.unique_name |
3370 | 631 | self.assertGitRepositoryNotFound( | 631 | self.assertGitRepositoryNotFound( |
3371 | 632 | other_person, path, can_authenticate=True) | 632 | other_person, path, can_authenticate=True) |
3372 | 633 | 633 | ||
3373 | @@ -642,34 +642,34 @@ class TestGitAPIMixin: | |||
3374 | 642 | self.factory.makeGitRepository(owner=user_a)) | 642 | self.factory.makeGitRepository(owner=user_a)) |
3375 | 643 | 643 | ||
3376 | 644 | rule = self.factory.makeGitRule( | 644 | rule = self.factory.makeGitRule( |
3378 | 645 | repository, ref_pattern=u'refs/heads/stable/next') | 645 | repository, ref_pattern='refs/heads/stable/next') |
3379 | 646 | self.factory.makeGitRuleGrant( | 646 | self.factory.makeGitRuleGrant( |
3380 | 647 | rule=rule, grantee=GitGranteeType.REPOSITORY_OWNER, | 647 | rule=rule, grantee=GitGranteeType.REPOSITORY_OWNER, |
3381 | 648 | can_force_push=True) | 648 | can_force_push=True) |
3382 | 649 | 649 | ||
3383 | 650 | rule = self.factory.makeGitRule( | 650 | rule = self.factory.makeGitRule( |
3385 | 651 | repository, ref_pattern=u'refs/heads/stable/protected') | 651 | repository, ref_pattern='refs/heads/stable/protected') |
3386 | 652 | self.factory.makeGitRuleGrant(rule=rule, grantee=stable_team) | 652 | self.factory.makeGitRuleGrant(rule=rule, grantee=stable_team) |
3387 | 653 | 653 | ||
3388 | 654 | rule = self.factory.makeGitRule( | 654 | rule = self.factory.makeGitRule( |
3390 | 655 | repository, ref_pattern=u'refs/heads/archived/*') | 655 | repository, ref_pattern='refs/heads/archived/*') |
3391 | 656 | self.factory.makeGitRuleGrant( | 656 | self.factory.makeGitRuleGrant( |
3392 | 657 | rule=rule, grantee=GitGranteeType.REPOSITORY_OWNER) | 657 | rule=rule, grantee=GitGranteeType.REPOSITORY_OWNER) |
3393 | 658 | self.factory.makeGitRuleGrant( | 658 | self.factory.makeGitRuleGrant( |
3394 | 659 | rule=rule, grantee=user_b, can_create=True) | 659 | rule=rule, grantee=user_b, can_create=True) |
3395 | 660 | 660 | ||
3396 | 661 | rule = self.factory.makeGitRule( | 661 | rule = self.factory.makeGitRule( |
3398 | 662 | repository, ref_pattern=u'refs/heads/stable/*') | 662 | repository, ref_pattern='refs/heads/stable/*') |
3399 | 663 | self.factory.makeGitRuleGrant( | 663 | self.factory.makeGitRuleGrant( |
3400 | 664 | rule=rule, grantee=stable_team, can_push=True) | 664 | rule=rule, grantee=stable_team, can_push=True) |
3401 | 665 | 665 | ||
3402 | 666 | rule = self.factory.makeGitRule( | 666 | rule = self.factory.makeGitRule( |
3404 | 667 | repository, ref_pattern=u'refs/heads/*/next') | 667 | repository, ref_pattern='refs/heads/*/next') |
3405 | 668 | self.factory.makeGitRuleGrant( | 668 | self.factory.makeGitRuleGrant( |
3406 | 669 | rule=rule, grantee=next_team, can_force_push=True) | 669 | rule=rule, grantee=next_team, can_force_push=True) |
3407 | 670 | 670 | ||
3408 | 671 | rule = self.factory.makeGitRule( | 671 | rule = self.factory.makeGitRule( |
3410 | 672 | repository, ref_pattern=u'refs/tags/*') | 672 | repository, ref_pattern='refs/tags/*') |
3411 | 673 | self.factory.makeGitRuleGrant( | 673 | self.factory.makeGitRuleGrant( |
3412 | 674 | rule=rule, grantee=GitGranteeType.REPOSITORY_OWNER, | 674 | rule=rule, grantee=GitGranteeType.REPOSITORY_OWNER, |
3413 | 675 | can_create=True) | 675 | can_create=True) |
3414 | @@ -743,18 +743,18 @@ class TestGitAPIMixin: | |||
3415 | 743 | self.factory.makeGitRepository(owner=user_a)) | 743 | self.factory.makeGitRepository(owner=user_a)) |
3416 | 744 | 744 | ||
3417 | 745 | rule = self.factory.makeGitRule( | 745 | rule = self.factory.makeGitRule( |
3419 | 746 | repository, ref_pattern=u'refs/heads/master') | 746 | repository, ref_pattern='refs/heads/master') |
3420 | 747 | self.factory.makeGitRuleGrant( | 747 | self.factory.makeGitRuleGrant( |
3421 | 748 | rule=rule, grantee=user_b, can_push=True) | 748 | rule=rule, grantee=user_b, can_push=True) |
3422 | 749 | 749 | ||
3423 | 750 | rule = self.factory.makeGitRule( | 750 | rule = self.factory.makeGitRule( |
3425 | 751 | repository, ref_pattern=u'refs/heads/*') | 751 | repository, ref_pattern='refs/heads/*') |
3426 | 752 | self.factory.makeGitRuleGrant( | 752 | self.factory.makeGitRuleGrant( |
3427 | 753 | rule=rule, grantee=GitGranteeType.REPOSITORY_OWNER, | 753 | rule=rule, grantee=GitGranteeType.REPOSITORY_OWNER, |
3428 | 754 | can_create=True, can_push=True, can_force_push=True) | 754 | can_create=True, can_push=True, can_force_push=True) |
3429 | 755 | 755 | ||
3430 | 756 | rule = self.factory.makeGitRule( | 756 | rule = self.factory.makeGitRule( |
3432 | 757 | repository, ref_pattern=u'refs/tags/*') | 757 | repository, ref_pattern='refs/tags/*') |
3433 | 758 | self.factory.makeGitRuleGrant( | 758 | self.factory.makeGitRuleGrant( |
3434 | 759 | rule=rule, grantee=user_b, can_push=True) | 759 | rule=rule, grantee=user_b, can_push=True) |
3435 | 760 | 760 | ||
3436 | @@ -797,11 +797,11 @@ class TestGitAPIMixin: | |||
3437 | 797 | repository = removeSecurityProxy( | 797 | repository = removeSecurityProxy( |
3438 | 798 | self.factory.makeGitRepository(owner=owner)) | 798 | self.factory.makeGitRepository(owner=owner)) |
3439 | 799 | self.factory.makeGitRuleGrant( | 799 | self.factory.makeGitRuleGrant( |
3441 | 800 | repository=repository, ref_pattern=u"refs/heads/next/*", | 800 | repository=repository, ref_pattern="refs/heads/next/*", |
3442 | 801 | grantee=grantee, can_push=True) | 801 | grantee=grantee, can_push=True) |
3443 | 802 | paths = [ | 802 | paths = [ |
3444 | 803 | # Properly-encoded UTF-8. | 803 | # Properly-encoded UTF-8. |
3446 | 804 | u"refs/heads/next/\N{BLACK HEART SUIT}".encode("UTF-8"), | 804 | "refs/heads/next/\N{BLACK HEART SUIT}".encode(), |
3447 | 805 | # Non-UTF-8. (git does not require any particular encoding for | 805 | # Non-UTF-8. (git does not require any particular encoding for |
3448 | 806 | # ref paths; non-UTF-8 ones won't work well everywhere, but it's | 806 | # ref paths; non-UTF-8 ones won't work well everywhere, but it's |
3449 | 807 | # at least possible to round-trip them through Launchpad.) | 807 | # at least possible to round-trip them through Launchpad.) |
3450 | @@ -1211,12 +1211,12 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3451 | 1211 | # When this happens, it returns a Fault saying so, including the | 1211 | # When this happens, it returns a Fault saying so, including the |
3452 | 1212 | # path it couldn't translate. | 1212 | # path it couldn't translate. |
3453 | 1213 | requester = self.factory.makePerson() | 1213 | requester = self.factory.makePerson() |
3455 | 1214 | self.assertGitRepositoryNotFound(requester, u"/untranslatable") | 1214 | self.assertGitRepositoryNotFound(requester, "/untranslatable") |
3456 | 1215 | 1215 | ||
3457 | 1216 | def test_translatePath_repository(self): | 1216 | def test_translatePath_repository(self): |
3458 | 1217 | requester = self.factory.makePerson() | 1217 | requester = self.factory.makePerson() |
3459 | 1218 | repository = self.factory.makeGitRepository() | 1218 | repository = self.factory.makeGitRepository() |
3461 | 1219 | path = u"/%s" % repository.unique_name | 1219 | path = "/%s" % repository.unique_name |
3462 | 1220 | self.assertTranslates(requester, path, repository, False) | 1220 | self.assertTranslates(requester, path, repository, False) |
3463 | 1221 | 1221 | ||
3464 | 1222 | def test_translatePath_repository_with_no_leading_slash(self): | 1222 | def test_translatePath_repository_with_no_leading_slash(self): |
3465 | @@ -1228,30 +1228,30 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3466 | 1228 | def test_translatePath_repository_with_trailing_slash(self): | 1228 | def test_translatePath_repository_with_trailing_slash(self): |
3467 | 1229 | requester = self.factory.makePerson() | 1229 | requester = self.factory.makePerson() |
3468 | 1230 | repository = self.factory.makeGitRepository() | 1230 | repository = self.factory.makeGitRepository() |
3470 | 1231 | path = u"/%s/" % repository.unique_name | 1231 | path = "/%s/" % repository.unique_name |
3471 | 1232 | self.assertTranslates(requester, path, repository, False) | 1232 | self.assertTranslates(requester, path, repository, False) |
3472 | 1233 | 1233 | ||
3473 | 1234 | def test_translatePath_repository_with_trailing_segments(self): | 1234 | def test_translatePath_repository_with_trailing_segments(self): |
3474 | 1235 | requester = self.factory.makePerson() | 1235 | requester = self.factory.makePerson() |
3475 | 1236 | repository = self.factory.makeGitRepository() | 1236 | repository = self.factory.makeGitRepository() |
3477 | 1237 | path = u"/%s/foo/bar" % repository.unique_name | 1237 | path = "/%s/foo/bar" % repository.unique_name |
3478 | 1238 | self.assertTranslates( | 1238 | self.assertTranslates( |
3479 | 1239 | requester, path, repository, False, trailing="foo/bar") | 1239 | requester, path, repository, False, trailing="foo/bar") |
3480 | 1240 | 1240 | ||
3481 | 1241 | def test_translatePath_no_such_repository(self): | 1241 | def test_translatePath_no_such_repository(self): |
3482 | 1242 | requester = self.factory.makePerson() | 1242 | requester = self.factory.makePerson() |
3484 | 1243 | path = u"/%s/+git/no-such-repository" % requester.name | 1243 | path = "/%s/+git/no-such-repository" % requester.name |
3485 | 1244 | self.assertGitRepositoryNotFound(requester, path) | 1244 | self.assertGitRepositoryNotFound(requester, path) |
3486 | 1245 | 1245 | ||
3487 | 1246 | def test_translatePath_no_such_repository_non_ascii(self): | 1246 | def test_translatePath_no_such_repository_non_ascii(self): |
3488 | 1247 | requester = self.factory.makePerson() | 1247 | requester = self.factory.makePerson() |
3490 | 1248 | path = u"/%s/+git/\N{LATIN SMALL LETTER I WITH DIAERESIS}" % ( | 1248 | path = "/%s/+git/\N{LATIN SMALL LETTER I WITH DIAERESIS}" % ( |
3491 | 1249 | requester.name) | 1249 | requester.name) |
3492 | 1250 | self.assertGitRepositoryNotFound(requester, path) | 1250 | self.assertGitRepositoryNotFound(requester, path) |
3493 | 1251 | 1251 | ||
3494 | 1252 | def test_translatePath_anonymous_public_repository(self): | 1252 | def test_translatePath_anonymous_public_repository(self): |
3495 | 1253 | repository = self.factory.makeGitRepository() | 1253 | repository = self.factory.makeGitRepository() |
3497 | 1254 | path = u"/%s" % repository.unique_name | 1254 | path = "/%s" % repository.unique_name |
3498 | 1255 | self.assertTranslates( | 1255 | self.assertTranslates( |
3499 | 1256 | None, path, repository, False, can_authenticate=False) | 1256 | None, path, repository, False, can_authenticate=False) |
3500 | 1257 | self.assertTranslates( | 1257 | self.assertTranslates( |
3501 | @@ -1260,7 +1260,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3502 | 1260 | def test_translatePath_owned(self): | 1260 | def test_translatePath_owned(self): |
3503 | 1261 | requester = self.factory.makePerson() | 1261 | requester = self.factory.makePerson() |
3504 | 1262 | repository = self.factory.makeGitRepository(owner=requester) | 1262 | repository = self.factory.makeGitRepository(owner=requester) |
3506 | 1263 | path = u"/%s" % repository.unique_name | 1263 | path = "/%s" % repository.unique_name |
3507 | 1264 | self.assertTranslates( | 1264 | self.assertTranslates( |
3508 | 1265 | requester, path, repository, True, permission="write") | 1265 | requester, path, repository, True, permission="write") |
3509 | 1266 | 1266 | ||
3510 | @@ -1268,7 +1268,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3511 | 1268 | requester = self.factory.makePerson() | 1268 | requester = self.factory.makePerson() |
3512 | 1269 | team = self.factory.makeTeam(requester) | 1269 | team = self.factory.makeTeam(requester) |
3513 | 1270 | repository = self.factory.makeGitRepository(owner=team) | 1270 | repository = self.factory.makeGitRepository(owner=team) |
3515 | 1271 | path = u"/%s" % repository.unique_name | 1271 | path = "/%s" % repository.unique_name |
3516 | 1272 | self.assertTranslates( | 1272 | self.assertTranslates( |
3517 | 1273 | requester, path, repository, True, permission="write") | 1273 | requester, path, repository, True, permission="write") |
3518 | 1274 | 1274 | ||
3519 | @@ -1279,7 +1279,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3520 | 1279 | with person_logged_in(repository.target.owner): | 1279 | with person_logged_in(repository.target.owner): |
3521 | 1280 | getUtility(IGitRepositorySet).setDefaultRepository( | 1280 | getUtility(IGitRepositorySet).setDefaultRepository( |
3522 | 1281 | repository.target, repository) | 1281 | repository.target, repository) |
3524 | 1282 | path = u"/%s" % repository.target.name | 1282 | path = "/%s" % repository.target.name |
3525 | 1283 | self.assertTranslates(requester, path, repository, False) | 1283 | self.assertTranslates(requester, path, repository, False) |
3526 | 1284 | 1284 | ||
3527 | 1285 | def test_translatePath_create_project_async(self): | 1285 | def test_translatePath_create_project_async(self): |
3528 | @@ -1288,14 +1288,14 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3529 | 1288 | requester = self.factory.makePerson() | 1288 | requester = self.factory.makePerson() |
3530 | 1289 | project = self.factory.makeProduct() | 1289 | project = self.factory.makeProduct() |
3531 | 1290 | self.assertCreates( | 1290 | self.assertCreates( |
3533 | 1291 | requester, u"/~%s/%s/+git/random" % (requester.name, project.name)) | 1291 | requester, "/~%s/%s/+git/random" % (requester.name, project.name)) |
3534 | 1292 | 1292 | ||
3535 | 1293 | def test_translatePath_create_project_sync(self): | 1293 | def test_translatePath_create_project_sync(self): |
3536 | 1294 | self.useFixture(FeatureFixture({GIT_ASYNC_CREATE_REPO: ''})) | 1294 | self.useFixture(FeatureFixture({GIT_ASYNC_CREATE_REPO: ''})) |
3537 | 1295 | requester = self.factory.makePerson() | 1295 | requester = self.factory.makePerson() |
3538 | 1296 | project = self.factory.makeProduct() | 1296 | project = self.factory.makeProduct() |
3539 | 1297 | self.assertCreates( | 1297 | self.assertCreates( |
3541 | 1298 | requester, u"/~%s/%s/+git/random" % (requester.name, project.name), | 1298 | requester, "/~%s/%s/+git/random" % (requester.name, project.name), |
3542 | 1299 | async_create=False) | 1299 | async_create=False) |
3543 | 1300 | 1300 | ||
3544 | 1301 | def test_translatePath_create_project_blocks_duplicate_calls(self): | 1301 | def test_translatePath_create_project_blocks_duplicate_calls(self): |
3545 | @@ -1303,7 +1303,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3546 | 1303 | # but blocks any further request to create the same repository. | 1303 | # but blocks any further request to create the same repository. |
3547 | 1304 | requester = self.factory.makePerson() | 1304 | requester = self.factory.makePerson() |
3548 | 1305 | project = self.factory.makeProduct() | 1305 | project = self.factory.makeProduct() |
3550 | 1306 | path = u"/~%s/%s/+git/random" % (requester.name, project.name) | 1306 | path = "/~%s/%s/+git/random" % (requester.name, project.name) |
3551 | 1307 | self.assertCreates(requester, path) | 1307 | self.assertCreates(requester, path) |
3552 | 1308 | 1308 | ||
3553 | 1309 | auth_params = _make_auth_params( | 1309 | auth_params = _make_auth_params( |
3554 | @@ -1323,7 +1323,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3555 | 1323 | self.repository_set.setDefaultRepository(target, repository) | 1323 | self.repository_set.setDefaultRepository(target, repository) |
3556 | 1324 | self.assertCreatesFromClone( | 1324 | self.assertCreatesFromClone( |
3557 | 1325 | target.owner, | 1325 | target.owner, |
3559 | 1326 | u"/~%s/%s/+git/random" % (target.owner.name, target.name), | 1326 | "/~%s/%s/+git/random" % (target.owner.name, target.name), |
3560 | 1327 | repository) | 1327 | repository) |
3561 | 1328 | 1328 | ||
3562 | 1329 | def test_translatePath_create_project_clone_from_owner_default(self): | 1329 | def test_translatePath_create_project_clone_from_owner_default(self): |
3563 | @@ -1337,7 +1337,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3564 | 1337 | target.owner, target, repository, user) | 1337 | target.owner, target, repository, user) |
3565 | 1338 | self.assertCreatesFromClone( | 1338 | self.assertCreatesFromClone( |
3566 | 1339 | target.owner, | 1339 | target.owner, |
3568 | 1340 | u"/~%s/%s/+git/random" % (target.owner.name, target.name), | 1340 | "/~%s/%s/+git/random" % (target.owner.name, target.name), |
3569 | 1341 | repository) | 1341 | repository) |
3570 | 1342 | 1342 | ||
3571 | 1343 | def test_translatePath_create_package(self): | 1343 | def test_translatePath_create_package(self): |
3572 | @@ -1347,7 +1347,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3573 | 1347 | dsp = self.factory.makeDistributionSourcePackage() | 1347 | dsp = self.factory.makeDistributionSourcePackage() |
3574 | 1348 | self.assertCreates( | 1348 | self.assertCreates( |
3575 | 1349 | requester, | 1349 | requester, |
3577 | 1350 | u"/~%s/%s/+source/%s/+git/random" % ( | 1350 | "/~%s/%s/+source/%s/+git/random" % ( |
3578 | 1351 | requester.name, | 1351 | requester.name, |
3579 | 1352 | dsp.distribution.name, dsp.sourcepackagename.name)) | 1352 | dsp.distribution.name, dsp.sourcepackagename.name)) |
3580 | 1353 | 1353 | ||
3581 | @@ -1358,45 +1358,45 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3582 | 1358 | oci_project = self.factory.makeOCIProject() | 1358 | oci_project = self.factory.makeOCIProject() |
3583 | 1359 | self.assertCreates( | 1359 | self.assertCreates( |
3584 | 1360 | requester, | 1360 | requester, |
3586 | 1361 | u"/~%s/%s/+oci/%s/+git/random" % ( | 1361 | "/~%s/%s/+oci/%s/+git/random" % ( |
3587 | 1362 | requester.name, oci_project.pillar.name, oci_project.name)) | 1362 | requester.name, oci_project.pillar.name, oci_project.name)) |
3588 | 1363 | 1363 | ||
3589 | 1364 | def test_translatePath_create_personal(self): | 1364 | def test_translatePath_create_personal(self): |
3590 | 1365 | # translatePath creates a personal repository that doesn't exist, if | 1365 | # translatePath creates a personal repository that doesn't exist, if |
3591 | 1366 | # it can. | 1366 | # it can. |
3592 | 1367 | requester = self.factory.makePerson() | 1367 | requester = self.factory.makePerson() |
3594 | 1368 | self.assertCreates(requester, u"/~%s/+git/random" % requester.name) | 1368 | self.assertCreates(requester, "/~%s/+git/random" % requester.name) |
3595 | 1369 | 1369 | ||
3596 | 1370 | def test_translatePath_create_personal_team(self): | 1370 | def test_translatePath_create_personal_team(self): |
3597 | 1371 | # translatePath creates a personal repository for a team of which | 1371 | # translatePath creates a personal repository for a team of which |
3598 | 1372 | # the requester is a member. | 1372 | # the requester is a member. |
3599 | 1373 | requester = self.factory.makePerson() | 1373 | requester = self.factory.makePerson() |
3600 | 1374 | team = self.factory.makeTeam(members=[requester]) | 1374 | team = self.factory.makeTeam(members=[requester]) |
3602 | 1375 | self.assertCreates(requester, u"/~%s/+git/random" % team.name) | 1375 | self.assertCreates(requester, "/~%s/+git/random" % team.name) |
3603 | 1376 | 1376 | ||
3604 | 1377 | def test_translatePath_create_native_string(self): | 1377 | def test_translatePath_create_native_string(self): |
3605 | 1378 | # On Python 2, ASCII strings come in as native strings, not Unicode | 1378 | # On Python 2, ASCII strings come in as native strings, not Unicode |
3606 | 1379 | # strings. They work fine too. | 1379 | # strings. They work fine too. |
3607 | 1380 | requester = self.factory.makePerson() | 1380 | requester = self.factory.makePerson() |
3608 | 1381 | project = self.factory.makeProduct() | 1381 | project = self.factory.makeProduct() |
3610 | 1382 | path = u"/~%s/%s/+git/random" % (requester.name, project.name) | 1382 | path = "/~%s/%s/+git/random" % (requester.name, project.name) |
3611 | 1383 | self.assertCreates(requester, six.ensure_str(path)) | 1383 | self.assertCreates(requester, six.ensure_str(path)) |
3612 | 1384 | 1384 | ||
3613 | 1385 | def test_translatePath_anonymous_cannot_create(self): | 1385 | def test_translatePath_anonymous_cannot_create(self): |
3614 | 1386 | # Anonymous users cannot create repositories. | 1386 | # Anonymous users cannot create repositories. |
3615 | 1387 | project = self.factory.makeProject() | 1387 | project = self.factory.makeProject() |
3616 | 1388 | self.assertGitRepositoryNotFound( | 1388 | self.assertGitRepositoryNotFound( |
3618 | 1389 | None, u"/%s" % project.name, permission="write", | 1389 | None, "/%s" % project.name, permission="write", |
3619 | 1390 | can_authenticate=False) | 1390 | can_authenticate=False) |
3620 | 1391 | self.assertUnauthorized( | 1391 | self.assertUnauthorized( |
3622 | 1392 | None, u"/%s" % project.name, permission="write", | 1392 | None, "/%s" % project.name, permission="write", |
3623 | 1393 | can_authenticate=True) | 1393 | can_authenticate=True) |
3624 | 1394 | 1394 | ||
3625 | 1395 | def test_translatePath_create_invalid_namespace(self): | 1395 | def test_translatePath_create_invalid_namespace(self): |
3626 | 1396 | # Trying to create a repository at a path that isn't valid for Git | 1396 | # Trying to create a repository at a path that isn't valid for Git |
3627 | 1397 | # repositories returns a PermissionDenied fault. | 1397 | # repositories returns a PermissionDenied fault. |
3628 | 1398 | requester = self.factory.makePerson() | 1398 | requester = self.factory.makePerson() |
3630 | 1399 | path = u"/~%s" % requester.name | 1399 | path = "/~%s" % requester.name |
3631 | 1400 | message = "'%s' is not a valid Git repository path." % path.strip("/") | 1400 | message = "'%s' is not a valid Git repository path." % path.strip("/") |
3632 | 1401 | self.assertPermissionDenied( | 1401 | self.assertPermissionDenied( |
3633 | 1402 | requester, path, message=message, permission="write") | 1402 | requester, path, message=message, permission="write") |
3634 | @@ -1405,14 +1405,14 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3635 | 1405 | # Creating a repository for a non-existent person fails. | 1405 | # Creating a repository for a non-existent person fails. |
3636 | 1406 | requester = self.factory.makePerson() | 1406 | requester = self.factory.makePerson() |
3637 | 1407 | self.assertNotFound( | 1407 | self.assertNotFound( |
3639 | 1408 | requester, u"/~nonexistent/+git/random", | 1408 | requester, "/~nonexistent/+git/random", |
3640 | 1409 | "User/team 'nonexistent' does not exist.", permission="write") | 1409 | "User/team 'nonexistent' does not exist.", permission="write") |
3641 | 1410 | 1410 | ||
3642 | 1411 | def test_translatePath_create_no_such_project(self): | 1411 | def test_translatePath_create_no_such_project(self): |
3643 | 1412 | # Creating a repository for a non-existent project fails. | 1412 | # Creating a repository for a non-existent project fails. |
3644 | 1413 | requester = self.factory.makePerson() | 1413 | requester = self.factory.makePerson() |
3645 | 1414 | self.assertNotFound( | 1414 | self.assertNotFound( |
3647 | 1415 | requester, u"/~%s/nonexistent/+git/random" % requester.name, | 1415 | requester, "/~%s/nonexistent/+git/random" % requester.name, |
3648 | 1416 | "Project 'nonexistent' does not exist.", permission="write") | 1416 | "Project 'nonexistent' does not exist.", permission="write") |
3649 | 1417 | 1417 | ||
3650 | 1418 | def test_translatePath_create_no_such_person_or_project(self): | 1418 | def test_translatePath_create_no_such_person_or_project(self): |
3651 | @@ -1420,14 +1420,14 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3652 | 1420 | # person is reported in preference. | 1420 | # person is reported in preference. |
3653 | 1421 | requester = self.factory.makePerson() | 1421 | requester = self.factory.makePerson() |
3654 | 1422 | self.assertNotFound( | 1422 | self.assertNotFound( |
3656 | 1423 | requester, u"/~nonexistent/nonexistent/+git/random", | 1423 | requester, "/~nonexistent/nonexistent/+git/random", |
3657 | 1424 | "User/team 'nonexistent' does not exist.", permission="write") | 1424 | "User/team 'nonexistent' does not exist.", permission="write") |
3658 | 1425 | 1425 | ||
3659 | 1426 | def test_translatePath_create_invalid_project(self): | 1426 | def test_translatePath_create_invalid_project(self): |
3660 | 1427 | # Creating a repository with an invalid project name fails. | 1427 | # Creating a repository with an invalid project name fails. |
3661 | 1428 | requester = self.factory.makePerson() | 1428 | requester = self.factory.makePerson() |
3662 | 1429 | self.assertNotFound( | 1429 | self.assertNotFound( |
3664 | 1430 | requester, u"/_bad_project/+git/random", | 1430 | requester, "/_bad_project/+git/random", |
3665 | 1431 | "Project '_bad_project' does not exist.", permission="write") | 1431 | "Project '_bad_project' does not exist.", permission="write") |
3666 | 1432 | 1432 | ||
3667 | 1433 | def test_translatePath_create_missing_sourcepackagename(self): | 1433 | def test_translatePath_create_missing_sourcepackagename(self): |
3668 | @@ -1436,7 +1436,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3669 | 1436 | requester = self.factory.makePerson() | 1436 | requester = self.factory.makePerson() |
3670 | 1437 | distro = self.factory.makeDistribution() | 1437 | distro = self.factory.makeDistribution() |
3671 | 1438 | repository_name = self.factory.getUniqueString() | 1438 | repository_name = self.factory.getUniqueString() |
3673 | 1439 | path = u"/~%s/%s/+source/new-package/+git/%s" % ( | 1439 | path = "/~%s/%s/+source/new-package/+git/%s" % ( |
3674 | 1440 | requester.name, distro.name, repository_name) | 1440 | requester.name, distro.name, repository_name) |
3675 | 1441 | repository = self.assertCreates(requester, path) | 1441 | repository = self.assertCreates(requester, path) |
3676 | 1442 | self.assertEqual( | 1442 | self.assertEqual( |
3677 | @@ -1447,7 +1447,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3678 | 1447 | requester = self.factory.makePerson() | 1447 | requester = self.factory.makePerson() |
3679 | 1448 | distro = self.factory.makeDistribution() | 1448 | distro = self.factory.makeDistribution() |
3680 | 1449 | repository_name = self.factory.getUniqueString() | 1449 | repository_name = self.factory.getUniqueString() |
3682 | 1450 | path = u"/~%s/%s/+source/new package/+git/%s" % ( | 1450 | path = "/~%s/%s/+source/new package/+git/%s" % ( |
3683 | 1451 | requester.name, distro.name, repository_name) | 1451 | requester.name, distro.name, repository_name) |
3684 | 1452 | self.assertInvalidSourcePackageName( | 1452 | self.assertInvalidSourcePackageName( |
3685 | 1453 | requester, path, "new package", permission="write") | 1453 | requester, path, "new package", permission="write") |
3686 | @@ -1457,7 +1457,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3687 | 1457 | requester = self.factory.makePerson() | 1457 | requester = self.factory.makePerson() |
3688 | 1458 | project = self.factory.makeProduct() | 1458 | project = self.factory.makeProduct() |
3689 | 1459 | invalid_name = "invalid name!" | 1459 | invalid_name = "invalid name!" |
3691 | 1460 | path = u"/~%s/%s/+git/%s" % ( | 1460 | path = "/~%s/%s/+git/%s" % ( |
3692 | 1461 | requester.name, project.name, invalid_name) | 1461 | requester.name, project.name, invalid_name) |
3693 | 1462 | # LaunchpadValidationError unfortunately assumes its output is | 1462 | # LaunchpadValidationError unfortunately assumes its output is |
3694 | 1463 | # always HTML, so it ends up double-escaped in XML-RPC faults. | 1463 | # always HTML, so it ends up double-escaped in XML-RPC faults. |
3695 | @@ -1471,8 +1471,8 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3696 | 1471 | # Creating a repository with a non-ASCII invalid name fails. | 1471 | # Creating a repository with a non-ASCII invalid name fails. |
3697 | 1472 | requester = self.factory.makePerson() | 1472 | requester = self.factory.makePerson() |
3698 | 1473 | project = self.factory.makeProduct() | 1473 | project = self.factory.makeProduct() |
3701 | 1474 | invalid_name = u"invalid\N{LATIN SMALL LETTER E WITH ACUTE}" | 1474 | invalid_name = "invalid\N{LATIN SMALL LETTER E WITH ACUTE}" |
3702 | 1475 | path = u"/~%s/%s/+git/%s" % ( | 1475 | path = "/~%s/%s/+git/%s" % ( |
3703 | 1476 | requester.name, project.name, invalid_name) | 1476 | requester.name, project.name, invalid_name) |
3704 | 1477 | # LaunchpadValidationError unfortunately assumes its output is | 1477 | # LaunchpadValidationError unfortunately assumes its output is |
3705 | 1478 | # always HTML, so it ends up double-escaped in XML-RPC faults. | 1478 | # always HTML, so it ends up double-escaped in XML-RPC faults. |
3706 | @@ -1490,7 +1490,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3707 | 1490 | membership_policy=TeamMembershipPolicy.RESTRICTED, | 1490 | membership_policy=TeamMembershipPolicy.RESTRICTED, |
3708 | 1491 | members=[requester]) | 1491 | members=[requester]) |
3709 | 1492 | project = self.factory.makeProduct(owner=owner) | 1492 | project = self.factory.makeProduct(owner=owner) |
3711 | 1493 | repository = self.assertCreates(requester, u"/%s" % project.name) | 1493 | repository = self.assertCreates(requester, "/%s" % project.name) |
3712 | 1494 | self.assertTrue(repository.target_default) | 1494 | self.assertTrue(repository.target_default) |
3713 | 1495 | self.assertTrue(repository.owner_default) | 1495 | self.assertTrue(repository.owner_default) |
3714 | 1496 | self.assertEqual(owner, repository.owner) | 1496 | self.assertEqual(owner, repository.owner) |
3715 | @@ -1500,7 +1500,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3716 | 1500 | # default for a package. | 1500 | # default for a package. |
3717 | 1501 | requester = self.factory.makePerson() | 1501 | requester = self.factory.makePerson() |
3718 | 1502 | dsp = self.factory.makeDistributionSourcePackage() | 1502 | dsp = self.factory.makeDistributionSourcePackage() |
3720 | 1503 | path = u"/%s/+source/%s" % ( | 1503 | path = "/%s/+source/%s" % ( |
3721 | 1504 | dsp.distribution.name, dsp.sourcepackagename.name) | 1504 | dsp.distribution.name, dsp.sourcepackagename.name) |
3722 | 1505 | message = ( | 1505 | message = ( |
3723 | 1506 | "Cannot automatically set the default repository for this target; " | 1506 | "Cannot automatically set the default repository for this target; " |
3724 | @@ -1518,7 +1518,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3725 | 1518 | oci_project = self.factory.makeOCIProject(pillar=distribution) | 1518 | oci_project = self.factory.makeOCIProject(pillar=distribution) |
3726 | 1519 | repository = self.assertCreates( | 1519 | repository = self.assertCreates( |
3727 | 1520 | requester, | 1520 | requester, |
3729 | 1521 | u"/%s/+oci/%s" % (oci_project.pillar.name, oci_project.name)) | 1521 | "/%s/+oci/%s" % (oci_project.pillar.name, oci_project.name)) |
3730 | 1522 | self.assertTrue(repository.target_default) | 1522 | self.assertTrue(repository.target_default) |
3731 | 1523 | self.assertTrue(repository.owner_default) | 1523 | self.assertTrue(repository.owner_default) |
3732 | 1524 | self.assertEqual(oci_project_admin, repository.owner) | 1524 | self.assertEqual(oci_project_admin, repository.owner) |
3733 | @@ -1529,7 +1529,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3734 | 1529 | # default for that OCI project. | 1529 | # default for that OCI project. |
3735 | 1530 | requester = self.factory.makePerson() | 1530 | requester = self.factory.makePerson() |
3736 | 1531 | oci_project = self.factory.makeOCIProject() | 1531 | oci_project = self.factory.makeOCIProject() |
3738 | 1532 | path = u"/%s/+oci/%s" % (oci_project.pillar.name, oci_project.name) | 1532 | path = "/%s/+oci/%s" % (oci_project.pillar.name, oci_project.name) |
3739 | 1533 | message = ( | 1533 | message = ( |
3740 | 1534 | "Cannot automatically set the default repository for this target; " | 1534 | "Cannot automatically set the default repository for this target; " |
3741 | 1535 | "push to a named repository instead.") | 1535 | "push to a named repository instead.") |
3742 | @@ -1547,7 +1547,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3743 | 1547 | requester = self.factory.makePerson() | 1547 | requester = self.factory.makePerson() |
3744 | 1548 | project = self.factory.makeProduct() | 1548 | project = self.factory.makeProduct() |
3745 | 1549 | repository = self.assertCreates( | 1549 | repository = self.assertCreates( |
3747 | 1550 | requester, u"/~%s/%s" % (requester.name, project.name)) | 1550 | requester, "/~%s/%s" % (requester.name, project.name)) |
3748 | 1551 | self.assertFalse(repository.target_default) | 1551 | self.assertFalse(repository.target_default) |
3749 | 1552 | self.assertTrue(repository.owner_default) | 1552 | self.assertTrue(repository.owner_default) |
3750 | 1553 | self.assertEqual(requester, repository.owner) | 1553 | self.assertEqual(requester, repository.owner) |
3751 | @@ -1559,7 +1559,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3752 | 1559 | team = self.factory.makeTeam(owner=requester) | 1559 | team = self.factory.makeTeam(owner=requester) |
3753 | 1560 | project = self.factory.makeProduct() | 1560 | project = self.factory.makeProduct() |
3754 | 1561 | repository = self.assertCreates( | 1561 | repository = self.assertCreates( |
3756 | 1562 | requester, u"/~%s/%s" % (team.name, project.name)) | 1562 | requester, "/~%s/%s" % (team.name, project.name)) |
3757 | 1563 | self.assertFalse(repository.target_default) | 1563 | self.assertFalse(repository.target_default) |
3758 | 1564 | self.assertTrue(repository.owner_default) | 1564 | self.assertTrue(repository.owner_default) |
3759 | 1565 | self.assertEqual(team, repository.owner) | 1565 | self.assertEqual(team, repository.owner) |
3760 | @@ -1571,7 +1571,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3761 | 1571 | team = self.factory.makeTeam(members=[requester]) | 1571 | team = self.factory.makeTeam(members=[requester]) |
3762 | 1572 | project = self.factory.makeProduct() | 1572 | project = self.factory.makeProduct() |
3763 | 1573 | repository = self.assertCreates( | 1573 | repository = self.assertCreates( |
3765 | 1574 | requester, u"/~%s/%s" % (team.name, project.name)) | 1574 | requester, "/~%s/%s" % (team.name, project.name)) |
3766 | 1575 | self.assertFalse(repository.target_default) | 1575 | self.assertFalse(repository.target_default) |
3767 | 1576 | self.assertTrue(repository.owner_default) | 1576 | self.assertTrue(repository.owner_default) |
3768 | 1577 | self.assertEqual(team, repository.owner) | 1577 | self.assertEqual(team, repository.owner) |
3769 | @@ -1581,7 +1581,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3770 | 1581 | # default for a package. | 1581 | # default for a package. |
3771 | 1582 | requester = self.factory.makePerson() | 1582 | requester = self.factory.makePerson() |
3772 | 1583 | dsp = self.factory.makeDistributionSourcePackage() | 1583 | dsp = self.factory.makeDistributionSourcePackage() |
3774 | 1584 | path = u"/~%s/%s/+source/%s" % ( | 1584 | path = "/~%s/%s/+source/%s" % ( |
3775 | 1585 | requester.name, dsp.distribution.name, dsp.sourcepackagename.name) | 1585 | requester.name, dsp.distribution.name, dsp.sourcepackagename.name) |
3776 | 1586 | repository = self.assertCreates(requester, path) | 1586 | repository = self.assertCreates(requester, path) |
3777 | 1587 | self.assertFalse(repository.target_default) | 1587 | self.assertFalse(repository.target_default) |
3778 | @@ -1594,7 +1594,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3779 | 1594 | requester = self.factory.makePerson() | 1594 | requester = self.factory.makePerson() |
3780 | 1595 | team = self.factory.makeTeam(owner=requester) | 1595 | team = self.factory.makeTeam(owner=requester) |
3781 | 1596 | dsp = self.factory.makeDistributionSourcePackage() | 1596 | dsp = self.factory.makeDistributionSourcePackage() |
3783 | 1597 | path = u"/~%s/%s/+source/%s" % ( | 1597 | path = "/~%s/%s/+source/%s" % ( |
3784 | 1598 | team.name, dsp.distribution.name, dsp.sourcepackagename.name) | 1598 | team.name, dsp.distribution.name, dsp.sourcepackagename.name) |
3785 | 1599 | repository = self.assertCreates(requester, path) | 1599 | repository = self.assertCreates(requester, path) |
3786 | 1600 | self.assertFalse(repository.target_default) | 1600 | self.assertFalse(repository.target_default) |
3787 | @@ -1607,7 +1607,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3788 | 1607 | requester = self.factory.makePerson() | 1607 | requester = self.factory.makePerson() |
3789 | 1608 | team = self.factory.makeTeam(members=[requester]) | 1608 | team = self.factory.makeTeam(members=[requester]) |
3790 | 1609 | dsp = self.factory.makeDistributionSourcePackage() | 1609 | dsp = self.factory.makeDistributionSourcePackage() |
3792 | 1610 | path = u"/~%s/%s/+source/%s" % ( | 1610 | path = "/~%s/%s/+source/%s" % ( |
3793 | 1611 | team.name, dsp.distribution.name, dsp.sourcepackagename.name) | 1611 | team.name, dsp.distribution.name, dsp.sourcepackagename.name) |
3794 | 1612 | repository = self.assertCreates(requester, path) | 1612 | repository = self.assertCreates(requester, path) |
3795 | 1613 | self.assertFalse(repository.target_default) | 1613 | self.assertFalse(repository.target_default) |
3796 | @@ -1619,7 +1619,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3797 | 1619 | # default for an OCI project. | 1619 | # default for an OCI project. |
3798 | 1620 | requester = self.factory.makePerson() | 1620 | requester = self.factory.makePerson() |
3799 | 1621 | oci_project = self.factory.makeOCIProject() | 1621 | oci_project = self.factory.makeOCIProject() |
3801 | 1622 | path = u"/~%s/%s/+oci/%s" % ( | 1622 | path = "/~%s/%s/+oci/%s" % ( |
3802 | 1623 | requester.name, oci_project.pillar.name, oci_project.name) | 1623 | requester.name, oci_project.pillar.name, oci_project.name) |
3803 | 1624 | repository = self.assertCreates(requester, path) | 1624 | repository = self.assertCreates(requester, path) |
3804 | 1625 | self.assertFalse(repository.target_default) | 1625 | self.assertFalse(repository.target_default) |
3805 | @@ -1632,7 +1632,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3806 | 1632 | requester = self.factory.makePerson() | 1632 | requester = self.factory.makePerson() |
3807 | 1633 | team = self.factory.makeTeam(owner=requester) | 1633 | team = self.factory.makeTeam(owner=requester) |
3808 | 1634 | oci_project = self.factory.makeOCIProject() | 1634 | oci_project = self.factory.makeOCIProject() |
3810 | 1635 | path = u"/~%s/%s/+oci/%s" % ( | 1635 | path = "/~%s/%s/+oci/%s" % ( |
3811 | 1636 | team.name, oci_project.pillar.name, oci_project.name) | 1636 | team.name, oci_project.pillar.name, oci_project.name) |
3812 | 1637 | repository = self.assertCreates(requester, path) | 1637 | repository = self.assertCreates(requester, path) |
3813 | 1638 | self.assertFalse(repository.target_default) | 1638 | self.assertFalse(repository.target_default) |
3814 | @@ -1645,7 +1645,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3815 | 1645 | requester = self.factory.makePerson() | 1645 | requester = self.factory.makePerson() |
3816 | 1646 | team = self.factory.makeTeam(members=[requester]) | 1646 | team = self.factory.makeTeam(members=[requester]) |
3817 | 1647 | oci_project = self.factory.makeOCIProject() | 1647 | oci_project = self.factory.makeOCIProject() |
3819 | 1648 | path = u"/~%s/%s/+oci/%s" % ( | 1648 | path = "/~%s/%s/+oci/%s" % ( |
3820 | 1649 | team.name, oci_project.pillar.name, oci_project.name) | 1649 | team.name, oci_project.pillar.name, oci_project.name) |
3821 | 1650 | repository = self.assertCreates(requester, path) | 1650 | repository = self.assertCreates(requester, path) |
3822 | 1651 | self.assertFalse(repository.target_default) | 1651 | self.assertFalse(repository.target_default) |
3823 | @@ -1661,7 +1661,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3824 | 1661 | requester = self.factory.makePerson() | 1661 | requester = self.factory.makePerson() |
3825 | 1662 | initial_count = getUtility(IAllGitRepositories).count() | 1662 | initial_count = getUtility(IAllGitRepositories).count() |
3826 | 1663 | oops_id = self.assertOopsOccurred( | 1663 | oops_id = self.assertOopsOccurred( |
3828 | 1664 | requester, u"/~%s/+git/random" % requester.name, | 1664 | requester, "/~%s/+git/random" % requester.name, |
3829 | 1665 | permission="write") | 1665 | permission="write") |
3830 | 1666 | login(ANONYMOUS) | 1666 | login(ANONYMOUS) |
3831 | 1667 | self.assertEqual( | 1667 | self.assertEqual( |
3832 | @@ -1691,7 +1691,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3833 | 1691 | issuer = getUtility(IMacaroonIssuer, "code-import-job") | 1691 | issuer = getUtility(IMacaroonIssuer, "code-import-job") |
3834 | 1692 | macaroons = [ | 1692 | macaroons = [ |
3835 | 1693 | removeSecurityProxy(issuer).issueMacaroon(job) for job in jobs] | 1693 | removeSecurityProxy(issuer).issueMacaroon(job) for job in jobs] |
3837 | 1694 | path = u"/%s" % code_imports[0].git_repository.unique_name | 1694 | path = "/%s" % code_imports[0].git_repository.unique_name |
3838 | 1695 | self.assertUnauthorized( | 1695 | self.assertUnauthorized( |
3839 | 1696 | LAUNCHPAD_SERVICES, path, permission="write", | 1696 | LAUNCHPAD_SERVICES, path, permission="write", |
3840 | 1697 | macaroon_raw=macaroons[0].serialize()) | 1697 | macaroon_raw=macaroons[0].serialize()) |
3841 | @@ -1735,7 +1735,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3842 | 1735 | issuer = getUtility(IMacaroonIssuer, "code-import-job") | 1735 | issuer = getUtility(IMacaroonIssuer, "code-import-job") |
3843 | 1736 | macaroons = [ | 1736 | macaroons = [ |
3844 | 1737 | removeSecurityProxy(issuer).issueMacaroon(job) for job in jobs] | 1737 | removeSecurityProxy(issuer).issueMacaroon(job) for job in jobs] |
3846 | 1738 | path = u"/%s" % code_imports[0].git_repository.unique_name | 1738 | path = "/%s" % code_imports[0].git_repository.unique_name |
3847 | 1739 | self.assertUnauthorized( | 1739 | self.assertUnauthorized( |
3848 | 1740 | LAUNCHPAD_SERVICES, path, permission="write", | 1740 | LAUNCHPAD_SERVICES, path, permission="write", |
3849 | 1741 | macaroon_raw=macaroons[0].serialize()) | 1741 | macaroon_raw=macaroons[0].serialize()) |
3850 | @@ -1780,7 +1780,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3851 | 1780 | removeSecurityProxy(issuer).issueMacaroon(build) | 1780 | removeSecurityProxy(issuer).issueMacaroon(build) |
3852 | 1781 | for build in builds] | 1781 | for build in builds] |
3853 | 1782 | repository = refs[0].repository | 1782 | repository = refs[0].repository |
3855 | 1783 | path = u"/%s" % repository.unique_name | 1783 | path = "/%s" % repository.unique_name |
3856 | 1784 | self.assertUnauthorized( | 1784 | self.assertUnauthorized( |
3857 | 1785 | LAUNCHPAD_SERVICES, path, permission="write", | 1785 | LAUNCHPAD_SERVICES, path, permission="write", |
3858 | 1786 | macaroon_raw=macaroons[0].serialize()) | 1786 | macaroon_raw=macaroons[0].serialize()) |
3859 | @@ -1819,7 +1819,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3860 | 1819 | repository, user=requester) | 1819 | repository, user=requester) |
3861 | 1820 | for repository in repositories] | 1820 | for repository in repositories] |
3862 | 1821 | paths = [ | 1821 | paths = [ |
3864 | 1822 | u"/%s" % repository.unique_name for repository in repositories] | 1822 | "/%s" % repository.unique_name for repository in repositories] |
3865 | 1823 | for i, repository in enumerate(repositories): | 1823 | for i, repository in enumerate(repositories): |
3866 | 1824 | for j, macaroon in enumerate(macaroons): | 1824 | for j, macaroon in enumerate(macaroons): |
3867 | 1825 | login(ANONYMOUS) | 1825 | login(ANONYMOUS) |
3868 | @@ -1853,7 +1853,7 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3869 | 1853 | self.useFixture(ZopeUtilityFixture( | 1853 | self.useFixture(ZopeUtilityFixture( |
3870 | 1854 | issuer, IMacaroonIssuer, name="test")) | 1854 | issuer, IMacaroonIssuer, name="test")) |
3871 | 1855 | repository = self.factory.makeGitRepository() | 1855 | repository = self.factory.makeGitRepository() |
3873 | 1856 | path = u"/%s" % repository.unique_name | 1856 | path = "/%s" % repository.unique_name |
3874 | 1857 | macaroon = issuer.issueMacaroon(repository) | 1857 | macaroon = issuer.issueMacaroon(repository) |
3875 | 1858 | requesters = [self.factory.makePerson() for _ in range(2)] | 1858 | requesters = [self.factory.makePerson() for _ in range(2)] |
3876 | 1859 | for verified_user, authorized, unauthorized in ( | 1859 | for verified_user, authorized, unauthorized in ( |
3877 | @@ -1881,8 +1881,8 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3878 | 1881 | requester_owner = self.factory.makePerson() | 1881 | requester_owner = self.factory.makePerson() |
3879 | 1882 | repository = self.factory.makeGitRepository(owner=requester_owner) | 1882 | repository = self.factory.makeGitRepository(owner=requester_owner) |
3880 | 1883 | self.factory.makeGitRefs( | 1883 | self.factory.makeGitRefs( |
3883 | 1884 | repository=repository, paths=[u'refs/heads/master']) | 1884 | repository=repository, paths=['refs/heads/master']) |
3884 | 1885 | removeSecurityProxy(repository).default_branch = u'refs/heads/master' | 1885 | removeSecurityProxy(repository).default_branch = 'refs/heads/master' |
3885 | 1886 | pushed_branch = 'branch1' | 1886 | pushed_branch = 'branch1' |
3886 | 1887 | self.assertHasMergeProposalURL(repository, pushed_branch, | 1887 | self.assertHasMergeProposalURL(repository, pushed_branch, |
3887 | 1888 | {"uid": requester_owner.id}) | 1888 | {"uid": requester_owner.id}) |
3888 | @@ -1892,9 +1892,9 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3889 | 1892 | # Consequently LP will process any incoming branch from Turnip | 1892 | # Consequently LP will process any incoming branch from Turnip |
3890 | 1893 | # as being non default and produce a merge proposal URL for it. | 1893 | # as being non default and produce a merge proposal URL for it. |
3891 | 1894 | self.factory.makeGitRefs( | 1894 | self.factory.makeGitRefs( |
3893 | 1895 | repository=repository, paths=[u'refs/heads/%s' % pushed_branch]) | 1895 | repository=repository, paths=['refs/heads/%s' % pushed_branch]) |
3894 | 1896 | removeSecurityProxy(repository).default_branch = ( | 1896 | removeSecurityProxy(repository).default_branch = ( |
3896 | 1897 | u'refs/heads/%s' % pushed_branch) | 1897 | 'refs/heads/%s' % pushed_branch) |
3897 | 1898 | self.assertHasMergeProposalURL(repository, pushed_branch, | 1898 | self.assertHasMergeProposalURL(repository, pushed_branch, |
3898 | 1899 | {"uid": requester_owner.id}) | 1899 | {"uid": requester_owner.id}) |
3899 | 1900 | 1900 | ||
3900 | @@ -1912,8 +1912,8 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3901 | 1912 | repository = self.factory.makeGitRepository(owner=requester) | 1912 | repository = self.factory.makeGitRepository(owner=requester) |
3902 | 1913 | issuer = getUtility(IMacaroonIssuer, "git-repository") | 1913 | issuer = getUtility(IMacaroonIssuer, "git-repository") |
3903 | 1914 | self.factory.makeGitRefs( | 1914 | self.factory.makeGitRefs( |
3906 | 1915 | repository=repository, paths=[u'refs/heads/master']) | 1915 | repository=repository, paths=['refs/heads/master']) |
3907 | 1916 | removeSecurityProxy(repository).default_branch = u'refs/heads/master' | 1916 | removeSecurityProxy(repository).default_branch = 'refs/heads/master' |
3908 | 1917 | 1917 | ||
3909 | 1918 | pushed_branch = 'branch1' | 1918 | pushed_branch = 'branch1' |
3910 | 1919 | with person_logged_in(requester): | 1919 | with person_logged_in(requester): |
3911 | @@ -1940,8 +1940,8 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory): | |||
3912 | 1940 | owner = self.factory.makeTeam(members=requesters) | 1940 | owner = self.factory.makeTeam(members=requesters) |
3913 | 1941 | repository = self.factory.makeGitRepository(owner=owner) | 1941 | repository = self.factory.makeGitRepository(owner=owner) |
3914 | 1942 | self.factory.makeGitRefs( | 1942 | self.factory.makeGitRefs( |
3917 | 1943 | repository=repository, paths=[u'refs/heads/master']) | 1943 | repository=repository, paths=['refs/heads/master']) |
3918 | 1944 | removeSecurityProxy(repository).default_branch = u'refs/heads/master' | 1944 | removeSecurityProxy(repository).default_branch = 'refs/heads/master' |
3919 | 1945 | pushed_branch = 'branch1' | 1945 | pushed_branch = 'branch1' |
3920 | 1946 | macaroon = issuer.issueMacaroon(repository) | 1946 | macaroon = issuer.issueMacaroon(repository) |
3921 | 1947 | 1947 |
Self-approving (mechanical).