Merge ~cjwatson/launchpad:deconfuse-isort into launchpad:master
- Git
- lp:~cjwatson/launchpad
- deconfuse-isort
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 0e00bf0f88a3faa22d5e2cb4f7e0f15ba9ce42a5 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:deconfuse-isort |
Merge into: | launchpad:master |
Diff against target: |
529 lines (+59/-94) 15 files modified
lib/contrib/glock.py (+0/-1) lib/lp/app/browser/tests/test_vocabulary.py (+1/-3) lib/lp/code/browser/tests/test_codeimport.py (+15/-15) lib/lp/code/bzr.py (+1/-1) lib/lp/code/interfaces/branch.py (+1/-1) lib/lp/code/interfaces/webservice.py (+3/-6) lib/lp/codehosting/puller/worker.py (+1/-1) lib/lp/registry/tests/test_prf_filter.py (+8/-18) lib/lp/registry/tests/test_prf_hose.py (+8/-25) lib/lp/registry/tests/test_prf_log.py (+8/-14) lib/lp/services/librarian/client.py (+2/-1) lib/lp/services/mail/notificationrecipientset.py (+6/-3) lib/lp/testing/layers.py (+2/-3) lib/lp/translations/scripts/translations_to_branch.py (+1/-1) lib/sqlobject/__init__.py (+2/-1) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cristian Gonzalez (community) | Approve | ||
Review via email: mp+406753@code.launchpad.net |
Commit message
Adjust various imports to confuse isort a little less
Description of the change
Move non-circular imports to their usual place near the top of the file. Avoid `cimport` as a local variable because `isort` gets that confused with the Cython keyword. Add `# isort: split` in a few cases where we need to stop `isort` moving things around.
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/lib/contrib/glock.py b/lib/contrib/glock.py | |||
2 | index de39d12..69def87 100644 | |||
3 | --- a/lib/contrib/glock.py | |||
4 | +++ b/lib/contrib/glock.py | |||
5 | @@ -29,7 +29,6 @@ __doc__ += '\n@author: %s (U{%s})\n@version: %s' % (__author__[0], | |||
6 | 29 | __author__[1], __version__) | 29 | __author__[1], __version__) |
7 | 30 | __all__ = ['GlobalLock', 'GlobalLockError', 'LockAlreadyAcquired', 'NotOwner'] | 30 | __all__ = ['GlobalLock', 'GlobalLockError', 'LockAlreadyAcquired', 'NotOwner'] |
8 | 31 | 31 | ||
9 | 32 | # Imports: | ||
10 | 33 | import sys, string, os, errno, re | 32 | import sys, string, os, errno, re |
11 | 34 | 33 | ||
12 | 35 | # System-dependent imports for locking implementation: | 34 | # System-dependent imports for locking implementation: |
13 | diff --git a/lib/lp/app/browser/tests/test_vocabulary.py b/lib/lp/app/browser/tests/test_vocabulary.py | |||
14 | index 2904d8c..7265281 100644 | |||
15 | --- a/lib/lp/app/browser/tests/test_vocabulary.py | |||
16 | +++ b/lib/lp/app/browser/tests/test_vocabulary.py | |||
17 | @@ -328,9 +328,7 @@ class TestProductPickerEntrySourceAdapter(TestCaseWithFactory): | |||
18 | 328 | def test_provides_commercial_subscription_expired(self): | 328 | def test_provides_commercial_subscription_expired(self): |
19 | 329 | product = self.factory.makeProduct(name='fnord') | 329 | product = self.factory.makeProduct(name='fnord') |
20 | 330 | self.factory.makeCommercialSubscription(product) | 330 | self.factory.makeCommercialSubscription(product) |
24 | 331 | import datetime | 331 | then = datetime(2005, 6, 15, 0, 0, 0, 0, pytz.UTC) |
22 | 332 | import pytz | ||
23 | 333 | then = datetime.datetime(2005, 6, 15, 0, 0, 0, 0, pytz.UTC) | ||
25 | 334 | with celebrity_logged_in('admin'): | 332 | with celebrity_logged_in('admin'): |
26 | 335 | product.commercial_subscription.date_expires = then | 333 | product.commercial_subscription.date_expires = then |
27 | 336 | self.assertEqual( | 334 | self.assertEqual( |
28 | diff --git a/lib/lp/code/browser/tests/test_codeimport.py b/lib/lp/code/browser/tests/test_codeimport.py | |||
29 | index f8b1470..0dd76c6 100644 | |||
30 | --- a/lib/lp/code/browser/tests/test_codeimport.py | |||
31 | +++ b/lib/lp/code/browser/tests/test_codeimport.py | |||
32 | @@ -94,48 +94,48 @@ class TestImportDetails(TestCaseWithFactory): | |||
33 | 94 | 94 | ||
34 | 95 | def test_other_users_are_forbidden_to_change_codeimport(self): | 95 | def test_other_users_are_forbidden_to_change_codeimport(self): |
35 | 96 | # Unauthorized users are forbidden to edit an import. | 96 | # Unauthorized users are forbidden to edit an import. |
37 | 97 | cimport = self.factory.makeCodeImport() | 97 | code_import = self.factory.makeCodeImport() |
38 | 98 | another_person = self.factory.makePerson() | 98 | another_person = self.factory.makePerson() |
39 | 99 | with person_logged_in(another_person): | 99 | with person_logged_in(another_person): |
40 | 100 | self.assertRaises( | 100 | self.assertRaises( |
42 | 101 | Unauthorized, create_initialized_view, cimport.branch, | 101 | Unauthorized, create_initialized_view, code_import.branch, |
43 | 102 | '+edit-import') | 102 | '+edit-import') |
44 | 103 | 103 | ||
45 | 104 | def test_branch_owner_of_import_can_edit_it(self): | 104 | def test_branch_owner_of_import_can_edit_it(self): |
46 | 105 | # Owners are allowed to edit code import. | 105 | # Owners are allowed to edit code import. |
49 | 106 | cimport = self.factory.makeCodeImport() | 106 | code_import = self.factory.makeCodeImport() |
50 | 107 | with person_logged_in(cimport.branch.owner): | 107 | with person_logged_in(code_import.branch.owner): |
51 | 108 | view = create_initialized_view( | 108 | view = create_initialized_view( |
53 | 109 | cimport.branch, '+edit-import', form={ | 109 | code_import.branch, '+edit-import', form={ |
54 | 110 | "field.actions.update": "update", | 110 | "field.actions.update": "update", |
55 | 111 | "field.url": "http://foo.test" | 111 | "field.url": "http://foo.test" |
56 | 112 | }) | 112 | }) |
57 | 113 | self.assertEqual([], view.errors) | 113 | self.assertEqual([], view.errors) |
59 | 114 | self.assertEqual('http://foo.test', cimport.url) | 114 | self.assertEqual('http://foo.test', code_import.url) |
60 | 115 | 115 | ||
61 | 116 | def test_branch_owner_of_import_cannot_change_status(self): | 116 | def test_branch_owner_of_import_cannot_change_status(self): |
62 | 117 | # Owners are allowed to edit code import. | 117 | # Owners are allowed to edit code import. |
66 | 118 | cimport = self.factory.makeCodeImport() | 118 | code_import = self.factory.makeCodeImport() |
67 | 119 | original_url = cimport.url | 119 | original_url = code_import.url |
68 | 120 | with person_logged_in(cimport.branch.owner): | 120 | with person_logged_in(code_import.branch.owner): |
69 | 121 | view = create_initialized_view( | 121 | view = create_initialized_view( |
71 | 122 | cimport.branch, '+edit-import', form={ | 122 | code_import.branch, '+edit-import', form={ |
72 | 123 | "field.actions.suspend": "Suspend", | 123 | "field.actions.suspend": "Suspend", |
73 | 124 | "field.url": "http://foo.test" | 124 | "field.url": "http://foo.test" |
74 | 125 | }) | 125 | }) |
75 | 126 | self.assertEqual([], view.errors) | 126 | self.assertEqual([], view.errors) |
77 | 127 | self.assertEqual(original_url, cimport.url) | 127 | self.assertEqual(original_url, code_import.url) |
78 | 128 | 128 | ||
79 | 129 | def test_admin_can_change_code_import_status(self): | 129 | def test_admin_can_change_code_import_status(self): |
80 | 130 | # Owners are allowed to edit code import. | 130 | # Owners are allowed to edit code import. |
82 | 131 | cimport = self.factory.makeCodeImport() | 131 | code_import = self.factory.makeCodeImport() |
83 | 132 | with admin_logged_in(): | 132 | with admin_logged_in(): |
84 | 133 | view = create_initialized_view( | 133 | view = create_initialized_view( |
86 | 134 | cimport.branch, '+edit-import', form={ | 134 | code_import.branch, '+edit-import', form={ |
87 | 135 | "field.actions.suspend": "Suspend", | 135 | "field.actions.suspend": "Suspend", |
88 | 136 | "field.url": "http://foo.test" | 136 | "field.url": "http://foo.test" |
89 | 137 | }) | 137 | }) |
90 | 138 | self.assertEqual([], view.errors) | 138 | self.assertEqual([], view.errors) |
92 | 139 | self.assertEqual("http://foo.test", cimport.url) | 139 | self.assertEqual("http://foo.test", code_import.url) |
93 | 140 | self.assertEqual( | 140 | self.assertEqual( |
95 | 141 | CodeImportReviewStatus.SUSPENDED, cimport.review_status) | 141 | CodeImportReviewStatus.SUSPENDED, code_import.review_status) |
96 | diff --git a/lib/lp/code/bzr.py b/lib/lp/code/bzr.py | |||
97 | index e823fc2..8e2e264 100644 | |||
98 | --- a/lib/lp/code/bzr.py | |||
99 | +++ b/lib/lp/code/bzr.py | |||
100 | @@ -19,7 +19,7 @@ __all__ = [ | |||
101 | 19 | 19 | ||
102 | 20 | # FIRST Ensure correct plugins are loaded. Do not delete this comment or the | 20 | # FIRST Ensure correct plugins are loaded. Do not delete this comment or the |
103 | 21 | # line below this comment. | 21 | # line below this comment. |
105 | 22 | import lp.codehosting # noqa: F401 | 22 | import lp.codehosting # noqa: F401 # isort: split |
106 | 23 | 23 | ||
107 | 24 | from breezy.branch import UnstackableBranchFormat | 24 | from breezy.branch import UnstackableBranchFormat |
108 | 25 | from breezy.bzr.branch import ( | 25 | from breezy.bzr.branch import ( |
109 | diff --git a/lib/lp/code/interfaces/branch.py b/lib/lp/code/interfaces/branch.py | |||
110 | index 45c8086..b8d52e5 100644 | |||
111 | --- a/lib/lp/code/interfaces/branch.py | |||
112 | +++ b/lib/lp/code/interfaces/branch.py | |||
113 | @@ -50,6 +50,7 @@ from lazr.restful.fields import ( | |||
114 | 50 | ReferenceChoice, | 50 | ReferenceChoice, |
115 | 51 | ) | 51 | ) |
116 | 52 | from lazr.restful.interface import copy_field | 52 | from lazr.restful.interface import copy_field |
117 | 53 | from lazr.uri import URI | ||
118 | 53 | from six.moves import http_client | 54 | from six.moves import http_client |
119 | 54 | from zope.component import getUtility | 55 | from zope.component import getUtility |
120 | 55 | from zope.interface import ( | 56 | from zope.interface import ( |
121 | @@ -157,7 +158,6 @@ class BranchURIField(URIField): | |||
122 | 157 | def _validate(self, value): | 158 | def _validate(self, value): |
123 | 158 | # import here to avoid circular import | 159 | # import here to avoid circular import |
124 | 159 | from lp.services.webapp import canonical_url | 160 | from lp.services.webapp import canonical_url |
125 | 160 | from lazr.uri import URI | ||
126 | 161 | 161 | ||
127 | 162 | # Can't use super-- this derives from an old-style class | 162 | # Can't use super-- this derives from an old-style class |
128 | 163 | URIField._validate(self, value) | 163 | URIField._validate(self, value) |
129 | diff --git a/lib/lp/code/interfaces/webservice.py b/lib/lp/code/interfaces/webservice.py | |||
130 | index 428c998..02546e9 100644 | |||
131 | --- a/lib/lp/code/interfaces/webservice.py | |||
132 | +++ b/lib/lp/code/interfaces/webservice.py | |||
133 | @@ -35,6 +35,9 @@ __all__ = [ | |||
134 | 35 | 'ISourcePackageRecipeBuild', | 35 | 'ISourcePackageRecipeBuild', |
135 | 36 | ] | 36 | ] |
136 | 37 | 37 | ||
137 | 38 | # XXX: JonathanLange 2010-11-09 bug=673083: Legacy work-around for circular | ||
138 | 39 | # import bugs. Break this up into a per-package thing. | ||
139 | 40 | from lp import _schema_circular_imports # noqa: F401 | ||
140 | 38 | # The exceptions are imported so that they can produce the special | 41 | # The exceptions are imported so that they can produce the special |
141 | 39 | # status code defined by error_status when they are raised. | 42 | # status code defined by error_status when they are raised. |
142 | 40 | from lp.code.errors import ( | 43 | from lp.code.errors import ( |
143 | @@ -70,9 +73,3 @@ from lp.code.interfaces.sourcepackagerecipe import ISourcePackageRecipe | |||
144 | 70 | from lp.code.interfaces.sourcepackagerecipebuild import ( | 73 | from lp.code.interfaces.sourcepackagerecipebuild import ( |
145 | 71 | ISourcePackageRecipeBuild, | 74 | ISourcePackageRecipeBuild, |
146 | 72 | ) | 75 | ) |
147 | 73 | |||
148 | 74 | |||
149 | 75 | # XXX: JonathanLange 2010-11-09 bug=673083: Legacy work-around for circular | ||
150 | 76 | # import bugs. Break this up into a per-package thing. | ||
151 | 77 | from lp import _schema_circular_imports | ||
152 | 78 | _schema_circular_imports | ||
153 | diff --git a/lib/lp/codehosting/puller/worker.py b/lib/lp/codehosting/puller/worker.py | |||
154 | index 4ccfcbe..e3c23a6 100644 | |||
155 | --- a/lib/lp/codehosting/puller/worker.py | |||
156 | +++ b/lib/lp/codehosting/puller/worker.py | |||
157 | @@ -8,7 +8,7 @@ import sys | |||
158 | 8 | 8 | ||
159 | 9 | # FIRST Ensure correct plugins are loaded. Do not delete this comment or the | 9 | # FIRST Ensure correct plugins are loaded. Do not delete this comment or the |
160 | 10 | # line below this comment. | 10 | # line below this comment. |
162 | 11 | import lp.codehosting # noqa: F401 | 11 | import lp.codehosting # noqa: F401 # isort: split |
163 | 12 | 12 | ||
164 | 13 | from breezy import ( | 13 | from breezy import ( |
165 | 14 | errors, | 14 | errors, |
166 | diff --git a/lib/lp/registry/tests/test_prf_filter.py b/lib/lp/registry/tests/test_prf_filter.py | |||
167 | index 1dc0d24..093dc79 100644 | |||
168 | --- a/lib/lp/registry/tests/test_prf_filter.py | |||
169 | +++ b/lib/lp/registry/tests/test_prf_filter.py | |||
170 | @@ -3,24 +3,24 @@ | |||
171 | 3 | 3 | ||
172 | 4 | """Tests for lp.registry.scripts.productreleasefinder.filter.""" | 4 | """Tests for lp.registry.scripts.productreleasefinder.filter.""" |
173 | 5 | 5 | ||
174 | 6 | import logging | ||
175 | 6 | import unittest | 7 | import unittest |
176 | 7 | 8 | ||
177 | 9 | from lp.registry.scripts.productreleasefinder.filter import ( | ||
178 | 10 | Filter, | ||
179 | 11 | FilterPattern, | ||
180 | 12 | ) | ||
181 | 13 | |||
182 | 8 | 14 | ||
183 | 9 | class Filter_Logging(unittest.TestCase): | 15 | class Filter_Logging(unittest.TestCase): |
184 | 10 | def testCreatesDefaultLogger(self): | 16 | def testCreatesDefaultLogger(self): |
185 | 11 | """Filter creates a default logger.""" | 17 | """Filter creates a default logger.""" |
186 | 12 | from lp.registry.scripts.productreleasefinder.filter import ( | ||
187 | 13 | Filter) | ||
188 | 14 | from logging import Logger | ||
189 | 15 | f = Filter() | 18 | f = Filter() |
191 | 16 | self.assertTrue(isinstance(f.log, Logger)) | 19 | self.assertTrue(isinstance(f.log, logging.Logger)) |
192 | 17 | 20 | ||
193 | 18 | def testCreatesChildLogger(self): | 21 | def testCreatesChildLogger(self): |
194 | 19 | """Filter creates a child logger if given a parent.""" | 22 | """Filter creates a child logger if given a parent.""" |
199 | 20 | from lp.registry.scripts.productreleasefinder.filter import ( | 23 | parent = logging.getLogger("foo") |
196 | 21 | Filter) | ||
197 | 22 | from logging import getLogger | ||
198 | 23 | parent = getLogger("foo") | ||
200 | 24 | f = Filter(log_parent=parent) | 24 | f = Filter(log_parent=parent) |
201 | 25 | self.assertEqual(f.log.parent, parent) | 25 | self.assertEqual(f.log.parent, parent) |
202 | 26 | 26 | ||
203 | @@ -28,15 +28,11 @@ class Filter_Logging(unittest.TestCase): | |||
204 | 28 | class Filter_Init(unittest.TestCase): | 28 | class Filter_Init(unittest.TestCase): |
205 | 29 | def testDefaultFiltersProperty(self): | 29 | def testDefaultFiltersProperty(self): |
206 | 30 | """Filter constructor initializes filters property to empty dict.""" | 30 | """Filter constructor initializes filters property to empty dict.""" |
207 | 31 | from lp.registry.scripts.productreleasefinder.filter import ( | ||
208 | 32 | Filter) | ||
209 | 33 | f = Filter() | 31 | f = Filter() |
210 | 34 | self.assertEqual(f.filters, []) | 32 | self.assertEqual(f.filters, []) |
211 | 35 | 33 | ||
212 | 36 | def testFiltersPropertyGiven(self): | 34 | def testFiltersPropertyGiven(self): |
213 | 37 | """Filter constructor accepts argument to set filters property.""" | 35 | """Filter constructor accepts argument to set filters property.""" |
214 | 38 | from lp.registry.scripts.productreleasefinder.filter import ( | ||
215 | 39 | Filter) | ||
216 | 40 | f = Filter(["wibble"]) | 36 | f = Filter(["wibble"]) |
217 | 41 | self.assertEqual(len(f.filters), 1) | 37 | self.assertEqual(len(f.filters), 1) |
218 | 42 | self.assertEqual(f.filters[0], "wibble") | 38 | self.assertEqual(f.filters[0], "wibble") |
219 | @@ -45,14 +41,10 @@ class Filter_Init(unittest.TestCase): | |||
220 | 45 | class Filter_CheckUrl(unittest.TestCase): | 41 | class Filter_CheckUrl(unittest.TestCase): |
221 | 46 | def testNoFilters(self): | 42 | def testNoFilters(self): |
222 | 47 | """Filter.check returns None if there are no filters.""" | 43 | """Filter.check returns None if there are no filters.""" |
223 | 48 | from lp.registry.scripts.productreleasefinder.filter import ( | ||
224 | 49 | Filter) | ||
225 | 50 | f = Filter() | 44 | f = Filter() |
226 | 51 | self.assertEqual(f.check("file:///subdir/file"), None) | 45 | self.assertEqual(f.check("file:///subdir/file"), None) |
227 | 52 | 46 | ||
228 | 53 | def makeFilter(self, key, urlglob): | 47 | def makeFilter(self, key, urlglob): |
229 | 54 | from lp.registry.scripts.productreleasefinder.filter import ( | ||
230 | 55 | Filter, FilterPattern) | ||
231 | 56 | pattern = FilterPattern(key, urlglob) | 48 | pattern = FilterPattern(key, urlglob) |
232 | 57 | return Filter([pattern]) | 49 | return Filter([pattern]) |
233 | 58 | 50 | ||
234 | @@ -85,8 +77,6 @@ class Filter_CheckUrl(unittest.TestCase): | |||
235 | 85 | class Filter_IsPossibleParentUrl(unittest.TestCase): | 77 | class Filter_IsPossibleParentUrl(unittest.TestCase): |
236 | 86 | 78 | ||
237 | 87 | def makeFilter(self, key, urlglob): | 79 | def makeFilter(self, key, urlglob): |
238 | 88 | from lp.registry.scripts.productreleasefinder.filter import ( | ||
239 | 89 | Filter, FilterPattern) | ||
240 | 90 | pattern = FilterPattern(key, urlglob) | 80 | pattern = FilterPattern(key, urlglob) |
241 | 91 | return Filter([pattern]) | 81 | return Filter([pattern]) |
242 | 92 | 82 | ||
243 | diff --git a/lib/lp/registry/tests/test_prf_hose.py b/lib/lp/registry/tests/test_prf_hose.py | |||
244 | index c679cc8..f56eb57 100644 | |||
245 | --- a/lib/lp/registry/tests/test_prf_hose.py | |||
246 | +++ b/lib/lp/registry/tests/test_prf_hose.py | |||
247 | @@ -3,11 +3,17 @@ | |||
248 | 3 | 3 | ||
249 | 4 | """Tests for lp.registry.scripts.productreleasefinder.hose.""" | 4 | """Tests for lp.registry.scripts.productreleasefinder.hose.""" |
250 | 5 | 5 | ||
251 | 6 | import logging | ||
252 | 6 | import os | 7 | import os |
253 | 7 | import shutil | 8 | import shutil |
254 | 8 | import tempfile | 9 | import tempfile |
255 | 9 | import unittest | 10 | import unittest |
256 | 10 | 11 | ||
257 | 12 | from lp.registry.scripts.productreleasefinder.filter import ( | ||
258 | 13 | Filter, | ||
259 | 14 | FilterPattern, | ||
260 | 15 | ) | ||
261 | 16 | from lp.registry.scripts.productreleasefinder.hose import Hose | ||
262 | 11 | from lp.testing import reset_logging | 17 | from lp.testing import reset_logging |
263 | 12 | 18 | ||
264 | 13 | 19 | ||
265 | @@ -68,16 +74,12 @@ class InstrumentedMethodObserver: | |||
266 | 68 | class Hose_Logging(unittest.TestCase): | 74 | class Hose_Logging(unittest.TestCase): |
267 | 69 | def testCreatesDefaultLogger(self): | 75 | def testCreatesDefaultLogger(self): |
268 | 70 | """Hose creates a default logger.""" | 76 | """Hose creates a default logger.""" |
269 | 71 | from lp.registry.scripts.productreleasefinder.hose import Hose | ||
270 | 72 | from logging import Logger | ||
271 | 73 | h = Hose() | 77 | h = Hose() |
273 | 74 | self.assertTrue(isinstance(h.log, Logger)) | 78 | self.assertTrue(isinstance(h.log, logging.Logger)) |
274 | 75 | 79 | ||
275 | 76 | def testCreatesChildLogger(self): | 80 | def testCreatesChildLogger(self): |
276 | 77 | """Hose creates a child logger if given a parent.""" | 81 | """Hose creates a child logger if given a parent.""" |
280 | 78 | from lp.registry.scripts.productreleasefinder.hose import Hose | 82 | parent = logging.getLogger("foo") |
278 | 79 | from logging import getLogger | ||
279 | 80 | parent = getLogger("foo") | ||
281 | 81 | h = Hose(log_parent=parent) | 83 | h = Hose(log_parent=parent) |
282 | 82 | self.assertEqual(h.log.parent, parent) | 84 | self.assertEqual(h.log.parent, parent) |
283 | 83 | 85 | ||
284 | @@ -85,23 +87,16 @@ class Hose_Logging(unittest.TestCase): | |||
285 | 85 | class Hose_Filter(unittest.TestCase): | 87 | class Hose_Filter(unittest.TestCase): |
286 | 86 | def testCreatesFilterObject(self): | 88 | def testCreatesFilterObject(self): |
287 | 87 | """Hose creates a Filter object.""" | 89 | """Hose creates a Filter object.""" |
288 | 88 | from lp.registry.scripts.productreleasefinder.hose import Hose | ||
289 | 89 | from lp.registry.scripts.productreleasefinder.filter import ( | ||
290 | 90 | Filter) | ||
291 | 91 | h = Hose() | 90 | h = Hose() |
292 | 92 | self.assertTrue(isinstance(h.filter, Filter)) | 91 | self.assertTrue(isinstance(h.filter, Filter)) |
293 | 93 | 92 | ||
294 | 94 | def testDefaultsFiltersToEmptyDict(self): | 93 | def testDefaultsFiltersToEmptyDict(self): |
295 | 95 | """Hose creates Filter object with empty dictionary.""" | 94 | """Hose creates Filter object with empty dictionary.""" |
296 | 96 | from lp.registry.scripts.productreleasefinder.hose import Hose | ||
297 | 97 | h = Hose() | 95 | h = Hose() |
298 | 98 | self.assertEqual(h.filter.filters, []) | 96 | self.assertEqual(h.filter.filters, []) |
299 | 99 | 97 | ||
300 | 100 | def testCreatesFiltersWithGiven(self): | 98 | def testCreatesFiltersWithGiven(self): |
301 | 101 | """Hose creates Filter object with dictionary given.""" | 99 | """Hose creates Filter object with dictionary given.""" |
302 | 102 | from lp.registry.scripts.productreleasefinder.hose import Hose | ||
303 | 103 | from lp.registry.scripts.productreleasefinder.filter import ( | ||
304 | 104 | FilterPattern) | ||
305 | 105 | pattern = FilterPattern("foo", "http:e*") | 100 | pattern = FilterPattern("foo", "http:e*") |
306 | 106 | h = Hose([pattern]) | 101 | h = Hose([pattern]) |
307 | 107 | self.assertEqual(len(h.filter.filters), 1) | 102 | self.assertEqual(len(h.filter.filters), 1) |
308 | @@ -111,7 +106,6 @@ class Hose_Filter(unittest.TestCase): | |||
309 | 111 | class Hose_Urls(unittest.TestCase): | 106 | class Hose_Urls(unittest.TestCase): |
310 | 112 | def testCallsReduceWork(self): | 107 | def testCallsReduceWork(self): |
311 | 113 | """Hose constructor calls reduceWork function.""" | 108 | """Hose constructor calls reduceWork function.""" |
312 | 114 | from lp.registry.scripts.productreleasefinder.hose import Hose | ||
313 | 115 | h = Hose.__new__(Hose) | 109 | h = Hose.__new__(Hose) |
314 | 116 | 110 | ||
315 | 117 | class Observer(InstrumentedMethodObserver): | 111 | class Observer(InstrumentedMethodObserver): |
316 | @@ -128,9 +122,6 @@ class Hose_Urls(unittest.TestCase): | |||
317 | 128 | 122 | ||
318 | 129 | def testPassesUrlList(self): | 123 | def testPassesUrlList(self): |
319 | 130 | """Hose constructor passes url list to reduceWork.""" | 124 | """Hose constructor passes url list to reduceWork.""" |
320 | 131 | from lp.registry.scripts.productreleasefinder.hose import Hose | ||
321 | 132 | from lp.registry.scripts.productreleasefinder.filter import ( | ||
322 | 133 | FilterPattern) | ||
323 | 134 | pattern = FilterPattern("foo", "http://archive.ubuntu.com/e*") | 125 | pattern = FilterPattern("foo", "http://archive.ubuntu.com/e*") |
324 | 135 | h = Hose.__new__(Hose) | 126 | h = Hose.__new__(Hose) |
325 | 136 | 127 | ||
326 | @@ -148,8 +139,6 @@ class Hose_Urls(unittest.TestCase): | |||
327 | 148 | 139 | ||
328 | 149 | def testSetsUrlProperty(self): | 140 | def testSetsUrlProperty(self): |
329 | 150 | """Hose constructor sets urls property to reduceWork return value.""" | 141 | """Hose constructor sets urls property to reduceWork return value.""" |
330 | 151 | from lp.registry.scripts.productreleasefinder.hose import Hose | ||
331 | 152 | |||
332 | 153 | class TestHose(Hose): | 142 | class TestHose(Hose): |
333 | 154 | def reduceWork(self, url_list): | 143 | def reduceWork(self, url_list): |
334 | 155 | return "wibble" | 144 | return "wibble" |
335 | @@ -161,20 +150,17 @@ class Hose_Urls(unittest.TestCase): | |||
336 | 161 | class Hose_ReduceWork(unittest.TestCase): | 150 | class Hose_ReduceWork(unittest.TestCase): |
337 | 162 | def testEmptyList(self): | 151 | def testEmptyList(self): |
338 | 163 | """Hose.reduceWork returns empty list when given one.""" | 152 | """Hose.reduceWork returns empty list when given one.""" |
339 | 164 | from lp.registry.scripts.productreleasefinder.hose import Hose | ||
340 | 165 | h = Hose() | 153 | h = Hose() |
341 | 166 | self.assertEqual(h.reduceWork([]), []) | 154 | self.assertEqual(h.reduceWork([]), []) |
342 | 167 | 155 | ||
343 | 168 | def testReducedList(self): | 156 | def testReducedList(self): |
344 | 169 | """Hose.reduceWork returns same list when nothing to do.""" | 157 | """Hose.reduceWork returns same list when nothing to do.""" |
345 | 170 | from lp.registry.scripts.productreleasefinder.hose import Hose | ||
346 | 171 | h = Hose() | 158 | h = Hose() |
347 | 172 | self.assertEqual(h.reduceWork(["http://localhost/", "file:///usr/"]), | 159 | self.assertEqual(h.reduceWork(["http://localhost/", "file:///usr/"]), |
348 | 173 | ["http://localhost/", "file:///usr/"]) | 160 | ["http://localhost/", "file:///usr/"]) |
349 | 174 | 161 | ||
350 | 175 | def testReducesList(self): | 162 | def testReducesList(self): |
351 | 176 | """Hose.reduceWork removes children elements from list.""" | 163 | """Hose.reduceWork removes children elements from list.""" |
352 | 177 | from lp.registry.scripts.productreleasefinder.hose import Hose | ||
353 | 178 | h = Hose() | 164 | h = Hose() |
354 | 179 | self.assertEqual(h.reduceWork(["http://localhost/", | 165 | self.assertEqual(h.reduceWork(["http://localhost/", |
355 | 180 | "http://localhost/foo/bar/", | 166 | "http://localhost/foo/bar/", |
356 | @@ -219,9 +205,6 @@ class Hose_LimitWalk(unittest.TestCase): | |||
357 | 219 | fp.close() | 205 | fp.close() |
358 | 220 | 206 | ||
359 | 221 | # Run the hose over the test data | 207 | # Run the hose over the test data |
360 | 222 | from lp.registry.scripts.productreleasefinder.hose import Hose | ||
361 | 223 | from lp.registry.scripts.productreleasefinder.filter import ( | ||
362 | 224 | FilterPattern) | ||
363 | 225 | pattern = FilterPattern("key", self.release_url + | 208 | pattern = FilterPattern("key", self.release_url + |
364 | 226 | "/foo/1.*/source/foo-1.*.tar.gz") | 209 | "/foo/1.*/source/foo-1.*.tar.gz") |
365 | 227 | hose = Hose([pattern]) | 210 | hose = Hose([pattern]) |
366 | diff --git a/lib/lp/registry/tests/test_prf_log.py b/lib/lp/registry/tests/test_prf_log.py | |||
367 | index d55f54f..2d663a0 100644 | |||
368 | --- a/lib/lp/registry/tests/test_prf_log.py | |||
369 | +++ b/lib/lp/registry/tests/test_prf_log.py | |||
370 | @@ -7,38 +7,32 @@ | |||
371 | 7 | 7 | ||
372 | 8 | __author__ = "Scott James Remnant <scott@canonical.com>" | 8 | __author__ = "Scott James Remnant <scott@canonical.com>" |
373 | 9 | 9 | ||
374 | 10 | import logging | ||
375 | 10 | import unittest | 11 | import unittest |
376 | 11 | 12 | ||
377 | 13 | from lp.registry.scripts.productreleasefinder.log import get_logger | ||
378 | 14 | |||
379 | 12 | 15 | ||
380 | 13 | class GetLogger(unittest.TestCase): | 16 | class GetLogger(unittest.TestCase): |
381 | 14 | def testLogger(self): | 17 | def testLogger(self): |
382 | 15 | """get_logger returns a Logger instance.""" | 18 | """get_logger returns a Logger instance.""" |
386 | 16 | from lp.registry.scripts.productreleasefinder.log import get_logger | 19 | self.assertTrue(isinstance(get_logger("test"), logging.Logger)) |
384 | 17 | from logging import Logger | ||
385 | 18 | self.assertTrue(isinstance(get_logger("test"), Logger)) | ||
387 | 19 | 20 | ||
388 | 20 | def testNoParent(self): | 21 | def testNoParent(self): |
389 | 21 | """get_logger works if no parent is given.""" | 22 | """get_logger works if no parent is given.""" |
390 | 22 | from lp.registry.scripts.productreleasefinder.log import get_logger | ||
391 | 23 | self.assertEqual(get_logger("test").name, "test") | 23 | self.assertEqual(get_logger("test").name, "test") |
392 | 24 | 24 | ||
393 | 25 | def testRootParent(self): | 25 | def testRootParent(self): |
394 | 26 | """get_logger works if root logger is given.""" | 26 | """get_logger works if root logger is given.""" |
398 | 27 | from lp.registry.scripts.productreleasefinder.log import get_logger | 27 | self.assertEqual(get_logger("test", logging.root).name, "test") |
396 | 28 | from logging import root | ||
397 | 29 | self.assertEqual(get_logger("test", root).name, "test") | ||
399 | 30 | 28 | ||
400 | 31 | def testNormalParent(self): | 29 | def testNormalParent(self): |
401 | 32 | """get_logger works if non-root logger is given.""" | 30 | """get_logger works if non-root logger is given.""" |
405 | 33 | from lp.registry.scripts.productreleasefinder.log import get_logger | 31 | parent = logging.getLogger("foo") |
403 | 34 | from logging import getLogger | ||
404 | 35 | parent = getLogger("foo") | ||
406 | 36 | self.assertEqual(get_logger("test", parent).name, "foo.test") | 32 | self.assertEqual(get_logger("test", parent).name, "foo.test") |
407 | 37 | 33 | ||
408 | 38 | def testDeepParent(self): | 34 | def testDeepParent(self): |
409 | 39 | """get_logger works if deep-level logger is given.""" | 35 | """get_logger works if deep-level logger is given.""" |
414 | 40 | from lp.registry.scripts.productreleasefinder.log import get_logger | 36 | logging.getLogger("foo") |
415 | 41 | from logging import getLogger | 37 | parent2 = logging.getLogger("foo.bar") |
412 | 42 | getLogger("foo") | ||
413 | 43 | parent2 = getLogger("foo.bar") | ||
416 | 44 | self.assertEqual(get_logger("test", parent2).name, "foo.bar.test") | 38 | self.assertEqual(get_logger("test", parent2).name, "foo.bar.test") |
417 | diff --git a/lib/lp/services/librarian/client.py b/lib/lp/services/librarian/client.py | |||
418 | index 6787768..a26e39f 100644 | |||
419 | --- a/lib/lp/services/librarian/client.py | |||
420 | +++ b/lib/lp/services/librarian/client.py | |||
421 | @@ -37,6 +37,7 @@ from six.moves.urllib.parse import ( | |||
422 | 37 | urlunparse, | 37 | urlunparse, |
423 | 38 | ) | 38 | ) |
424 | 39 | from six.moves.urllib.request import urlopen | 39 | from six.moves.urllib.request import urlopen |
425 | 40 | from sqlobject import SQLObjectNotFound | ||
426 | 40 | from storm.store import Store | 41 | from storm.store import Store |
427 | 41 | from zope.interface import implementer | 42 | from zope.interface import implementer |
428 | 42 | 43 | ||
429 | @@ -385,7 +386,7 @@ class FileDownloadClient: | |||
430 | 385 | inaccessible. | 386 | inaccessible. |
431 | 386 | """ | 387 | """ |
432 | 387 | from lp.services.librarian.model import LibraryFileAlias | 388 | from lp.services.librarian.model import LibraryFileAlias |
434 | 388 | from sqlobject import SQLObjectNotFound | 389 | |
435 | 389 | try: | 390 | try: |
436 | 390 | lfa = LibraryFileAlias.get(aliasID) | 391 | lfa = LibraryFileAlias.get(aliasID) |
437 | 391 | except SQLObjectNotFound: | 392 | except SQLObjectNotFound: |
438 | diff --git a/lib/lp/services/mail/notificationrecipientset.py b/lib/lp/services/mail/notificationrecipientset.py | |||
439 | index 7297da2..6004399 100644 | |||
440 | --- a/lib/lp/services/mail/notificationrecipientset.py | |||
441 | +++ b/lib/lp/services/mail/notificationrecipientset.py | |||
442 | @@ -14,7 +14,10 @@ from operator import attrgetter | |||
443 | 14 | 14 | ||
444 | 15 | import six | 15 | import six |
445 | 16 | from zope.interface import implementer | 16 | from zope.interface import implementer |
447 | 17 | from zope.security.proxy import isinstance as zope_isinstance | 17 | from zope.security.proxy import ( |
448 | 18 | isinstance as zope_isinstance, | ||
449 | 19 | removeSecurityProxy, | ||
450 | 20 | ) | ||
451 | 18 | 21 | ||
452 | 19 | from lp.registry.interfaces.person import IPerson | 22 | from lp.registry.interfaces.person import IPerson |
453 | 20 | from lp.services.mail.interfaces import ( | 23 | from lp.services.mail.interfaces import ( |
454 | @@ -107,8 +110,8 @@ class NotificationRecipientSet: | |||
455 | 107 | 110 | ||
456 | 108 | def add(self, persons, reason, header): | 111 | def add(self, persons, reason, header): |
457 | 109 | """See `INotificationRecipientSet`.""" | 112 | """See `INotificationRecipientSet`.""" |
458 | 110 | from zope.security.proxy import removeSecurityProxy | ||
459 | 111 | from lp.registry.model.person import get_recipients | 113 | from lp.registry.model.person import get_recipients |
460 | 114 | |||
461 | 112 | if (IPerson.providedBy(persons) or | 115 | if (IPerson.providedBy(persons) or |
462 | 113 | zope_isinstance(persons, StubPerson)): | 116 | zope_isinstance(persons, StubPerson)): |
463 | 114 | persons = [persons] | 117 | persons = [persons] |
464 | @@ -143,8 +146,8 @@ class NotificationRecipientSet: | |||
465 | 143 | 146 | ||
466 | 144 | def remove(self, persons): | 147 | def remove(self, persons): |
467 | 145 | """See `INotificationRecipientSet`.""" | 148 | """See `INotificationRecipientSet`.""" |
468 | 146 | from zope.security.proxy import removeSecurityProxy | ||
469 | 147 | from lp.registry.model.person import get_recipients | 149 | from lp.registry.model.person import get_recipients |
470 | 150 | |||
471 | 148 | if IPerson.providedBy(persons): | 151 | if IPerson.providedBy(persons): |
472 | 149 | persons = [persons] | 152 | persons = [persons] |
473 | 150 | for person in persons: | 153 | for person in persons: |
474 | diff --git a/lib/lp/testing/layers.py b/lib/lp/testing/layers.py | |||
475 | index 2d07f26..f6e931b 100644 | |||
476 | --- a/lib/lp/testing/layers.py | |||
477 | +++ b/lib/lp/testing/layers.py | |||
478 | @@ -78,6 +78,7 @@ from six.moves.urllib.error import ( | |||
479 | 78 | ) | 78 | ) |
480 | 79 | from six.moves.urllib.parse import urlparse | 79 | from six.moves.urllib.parse import urlparse |
481 | 80 | from six.moves.urllib.request import urlopen | 80 | from six.moves.urllib.request import urlopen |
482 | 81 | from storm.uri import URI | ||
483 | 81 | from talisker.context import Context | 82 | from talisker.context import Context |
484 | 82 | import transaction | 83 | import transaction |
485 | 83 | from webob.request import environ_from_url as orig_environ_from_url | 84 | from webob.request import environ_from_url as orig_environ_from_url |
486 | @@ -935,9 +936,7 @@ class LaunchpadLayer(LibrarianLayer, MemcachedLayer, RabbitMQLayer): | |||
487 | 935 | in the testSetUp(). | 936 | in the testSetUp(). |
488 | 936 | """ | 937 | """ |
489 | 937 | if LaunchpadLayer._raw_sessiondb_connection is None: | 938 | if LaunchpadLayer._raw_sessiondb_connection is None: |
493 | 938 | from storm.uri import URI | 939 | from lp.services.webapp.adapter import LaunchpadSessionDatabase |
491 | 939 | from lp.services.webapp.adapter import ( | ||
492 | 940 | LaunchpadSessionDatabase) | ||
494 | 941 | launchpad_session_database = LaunchpadSessionDatabase( | 940 | launchpad_session_database = LaunchpadSessionDatabase( |
495 | 942 | URI('launchpad-session:')) | 941 | URI('launchpad-session:')) |
496 | 943 | LaunchpadLayer._raw_sessiondb_connection = ( | 942 | LaunchpadLayer._raw_sessiondb_connection = ( |
497 | diff --git a/lib/lp/translations/scripts/translations_to_branch.py b/lib/lp/translations/scripts/translations_to_branch.py | |||
498 | index 0e57a88..f07abd5 100644 | |||
499 | --- a/lib/lp/translations/scripts/translations_to_branch.py | |||
500 | +++ b/lib/lp/translations/scripts/translations_to_branch.py | |||
501 | @@ -15,7 +15,7 @@ import os.path | |||
502 | 15 | 15 | ||
503 | 16 | # FIRST Ensure correct plugins are loaded. Do not delete this comment or the | 16 | # FIRST Ensure correct plugins are loaded. Do not delete this comment or the |
504 | 17 | # line below this comment. | 17 | # line below this comment. |
506 | 18 | import lp.codehosting # noqa: F401 | 18 | import lp.codehosting # noqa: F401 # isort: split |
507 | 19 | 19 | ||
508 | 20 | from breezy.errors import NotBranchError | 20 | from breezy.errors import NotBranchError |
509 | 21 | from breezy.revision import NULL_REVISION | 21 | from breezy.revision import NULL_REVISION |
510 | diff --git a/lib/sqlobject/__init__.py b/lib/sqlobject/__init__.py | |||
511 | index 3e5f9e4..5450477 100644 | |||
512 | --- a/lib/sqlobject/__init__.py | |||
513 | +++ b/lib/sqlobject/__init__.py | |||
514 | @@ -7,13 +7,14 @@ __metaclass__ = type | |||
515 | 7 | 7 | ||
516 | 8 | # SKIP this file when reformatting, due to the sys mangling. | 8 | # SKIP this file when reformatting, due to the sys mangling. |
517 | 9 | import datetime | 9 | import datetime |
518 | 10 | import sys | ||
519 | 10 | 11 | ||
520 | 11 | import six | 12 | import six |
521 | 12 | from storm.expr import SQL | 13 | from storm.expr import SQL |
522 | 13 | from storm.sqlobject import * # noqa: F401,F403 | 14 | from storm.sqlobject import * # noqa: F401,F403 |
523 | 14 | 15 | ||
524 | 16 | |||
525 | 15 | # Provide the same interface from these other locations. | 17 | # Provide the same interface from these other locations. |
526 | 16 | import sys | ||
527 | 17 | sys.modules['sqlobject.joins'] = sys.modules['sqlobject'] | 18 | sys.modules['sqlobject.joins'] = sys.modules['sqlobject'] |
528 | 18 | sys.modules['sqlobject.sqlbuilder'] = sys.modules['sqlobject'] | 19 | sys.modules['sqlobject.sqlbuilder'] = sys.modules['sqlobject'] |
529 | 19 | del sys | 20 | del sys |
Looks good!