Merge lp:~cjwatson/launchpad/upgrade-testtools into lp:launchpad

Proposed by Colin Watson on 2017-12-19
Status: Needs review
Proposed branch: lp:~cjwatson/launchpad/upgrade-testtools
Merge into: lp:launchpad
Prerequisite: lp:~cjwatson/launchpad/upgrade-keystoneclient-swiftclient
Diff against target: 392 lines (+33/-56)
17 files modified
constraints.txt (+4/-4)
lib/lp/bugs/model/tests/test_bugtask.py (+0/-1)
lib/lp/code/tests/helpers.py (+1/-2)
lib/lp/codehosting/codeimport/tests/test_worker.py (+2/-2)
lib/lp/codehosting/vfs/tests/test_branchfs.py (+3/-3)
lib/lp/registry/tests/test_subscribers.py (+0/-2)
lib/lp/scripts/runlaunchpad.py (+1/-2)
lib/lp/services/config/fixture.py (+2/-4)
lib/lp/services/features/testing.py (+1/-3)
lib/lp/services/librarianserver/testing/fake.py (+1/-2)
lib/lp/services/librarianserver/testing/tests/test_server_fixture.py (+1/-1)
lib/lp/services/memcache/testing.py (+1/-2)
lib/lp/services/utils.py (+1/-2)
lib/lp/snappy/browser/tests/test_snap.py (+2/-2)
lib/lp/testing/fixture.py (+9/-18)
lib/lp/testing/tests/test_layers_functional.py (+2/-4)
lib/lp/testing/tests/test_matchers.py (+2/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad/upgrade-testtools
Reviewer Review Type Date Requested Status
William Grant code 2017-12-19 Approve on 2018-01-02
Review via email: mp+335395@code.launchpad.net

Commit Message

Upgrade to testtools 2.3.0 and fixtures 3.0.0.

To post a comment you must log in.
18525. By Colin Watson on 2018-01-02

Upgrade to unittest2 1.1.0, which removes the need for security proxy fiddling around assertDictEqual.

William Grant (wgrant) :
review: Approve (code)

Unmerged revisions

18525. By Colin Watson on 2018-01-02

Upgrade to unittest2 1.1.0, which removes the need for security proxy fiddling around assertDictEqual.

18524. By Colin Watson on 2017-12-19

Upgrade to testtools 2.3.0 and fixtures 3.0.0.

18523. By Colin Watson on 2017-12-19

Just use "with fixture:" rather than "with self.useFixture(fixture):".

The latter form is redundant, and causes problems with newer versions of
fixtures.

18522. By Colin Watson on 2017-12-19

Remove security proxies before passing objects to assertDictEqual.

18521. By Colin Watson on 2017-12-19

Remove some stray calls to test case setUp methods.

18520. By Colin Watson on 2017-12-19

Use TestCase.skipTest rather than TestCase.skip (deprecated in testtools 1.9.0).

18519. By Colin Watson on 2017-12-19

Upgrade to python-keystoneclient 0.7.1 and python-swiftclient 2.0.3.

These were the latest versions in Icehouse, to go with keystone 2014.1.5 and
swift 1.13.1 currently on the server. Upgrading to these allows us to use a
more recent version of pbr that is compatible with other dependencies we'd
like to upgrade.

We need a few tweaks to make everything work properly:

 * quieten overly-noisy logging (needed until python-swiftclient 3.2.0);
 * explicitly restrict HashStream to the desired segment size, since
   otherwise the client will read past the end of the segment and we can end
   up with corrupted hashes;
 * advertise a keystone endpoint in the fake Swift fixture;
 * cope with slightly different exception types due to the client now using
   requests.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'constraints.txt'
2--- constraints.txt 2018-01-02 08:22:55 +0000
3+++ constraints.txt 2018-01-02 08:22:55 +0000
4@@ -140,7 +140,7 @@
5 setuptools==36.4.0
6 Sphinx==1.0.8
7 #testtools==0.9.12
8-testtools==0.9.30
9+testtools==2.3.0
10 transaction==1.1.1
11 z3c.recipe.sphinxdoc==0.0.8
12 zc.buildout==1.7.1
13@@ -246,10 +246,10 @@
14 dulwich==0.18.6
15 elementtree==1.2.6-20050316
16 epydoc==3.0.1
17-extras==0.0.3
18+extras==1.0.0
19 feedparser==4.1
20 feedvalidator==0.0.0DEV-r1049
21-fixtures==0.3.9
22+fixtures==3.0.0
23 FormEncode==1.2.4
24 grokcore.component==1.6
25 html5browser==0.0.9
26@@ -344,7 +344,7 @@
27 txlongpoll==0.2.12
28 txlongpollfixture==0.1.3
29 txpkgupload==0.2
30-unittest2==0.5.1
31+unittest2==1.1.0
32 van.testing==3.0.0
33 virtualenv-tools3==2.0.0
34 wadllib==1.3.2
35
36=== modified file 'lib/lp/bugs/model/tests/test_bugtask.py'
37--- lib/lp/bugs/model/tests/test_bugtask.py 2017-05-08 11:38:20 +0000
38+++ lib/lp/bugs/model/tests/test_bugtask.py 2018-01-02 08:22:55 +0000
39@@ -1630,7 +1630,6 @@
40 layer = DatabaseFunctionalLayer
41
42 def _setupBugData(self):
43- super(TestConjoinedBugTasks, self).setUp()
44 owner = self.factory.makePerson()
45 distro = self.factory.makeDistribution(name="eggs", owner=owner,
46 bug_supervisor=owner)
47
48=== modified file 'lib/lp/code/tests/helpers.py'
49--- lib/lp/code/tests/helpers.py 2017-10-04 01:53:48 +0000
50+++ lib/lp/code/tests/helpers.py 2018-01-02 08:22:55 +0000
51@@ -324,8 +324,7 @@
52 self.delete = FakeMethod()
53 self.disable_memcache = disable_memcache
54
55- def setUp(self):
56- super(GitHostingFixture, self).setUp()
57+ def _setUp(self):
58 self.useFixture(ZopeUtilityFixture(self, IGitHostingClient))
59 if self.disable_memcache:
60 # Most tests that involve GitRef._getLog don't want to cache the
61
62=== modified file 'lib/lp/codehosting/codeimport/tests/test_worker.py'
63--- lib/lp/codehosting/codeimport/tests/test_worker.py 2017-01-12 18:01:56 +0000
64+++ lib/lp/codehosting/codeimport/tests/test_worker.py 2018-01-02 08:22:55 +0000
65@@ -1266,12 +1266,12 @@
66 stacked_on_url=stacked_on_url)
67
68 def test_partial(self):
69- self.skip(
70+ self.skipTest(
71 "Partial fetching is not supported for native bzr branches "
72 "at the moment.")
73
74 def test_unsupported_feature(self):
75- self.skip("All Bazaar features are supported by Bazaar.")
76+ self.skipTest("All Bazaar features are supported by Bazaar.")
77
78 def test_reject_branch_reference(self):
79 # Branch references are allowed in the BzrImporter, but their URL
80
81=== modified file 'lib/lp/codehosting/vfs/tests/test_branchfs.py'
82--- lib/lp/codehosting/vfs/tests/test_branchfs.py 2013-08-16 05:16:44 +0000
83+++ lib/lp/codehosting/vfs/tests/test_branchfs.py 2018-01-02 08:22:55 +0000
84@@ -41,7 +41,6 @@
85 from testtools.deferredruntest import (
86 assert_fails_with,
87 AsynchronousDeferredRunTest,
88- run_with_log_observers,
89 )
90 from twisted.internet import defer
91
92@@ -1013,6 +1012,8 @@
93 class TestBranchChangedErrorHandling(TestCaseWithTransport, TestCase):
94 """Test handling of errors when branchChange is called."""
95
96+ run_tests_with = AsynchronousDeferredRunTest
97+
98 def setUp(self):
99 super(TestBranchChangedErrorHandling, self).setUp()
100 self._server = None
101@@ -1065,8 +1066,7 @@
102 # endpoint. We will then check the error handling.
103 db_branch = self.factory.makeAnyBranch(
104 branch_type=BranchType.HOSTED, owner=self.requester)
105- branch = run_with_log_observers(
106- [], self.make_branch, db_branch.unique_name)
107+ branch = self.make_branch(db_branch.unique_name)
108 branch.lock_write()
109 branch.unlock()
110 stderr_text = sys.stderr.getvalue()
111
112=== modified file 'lib/lp/registry/tests/test_subscribers.py'
113--- lib/lp/registry/tests/test_subscribers.py 2015-10-01 17:32:41 +0000
114+++ lib/lp/registry/tests/test_subscribers.py 2018-01-02 08:22:55 +0000
115@@ -99,8 +99,6 @@
116 layer = DatabaseFunctionalLayer
117
118 def make_product_user(self, licenses):
119- # Setup an a view that implements ProductLicenseMixin.
120- super(LicenseNotificationTestCase, self).setUp()
121 user = self.factory.makePerson(
122 name='registrant', email='registrant@launchpad.dev')
123 login_person(user)
124
125=== modified file 'lib/lp/scripts/runlaunchpad.py'
126--- lib/lp/scripts/runlaunchpad.py 2017-09-23 03:13:41 +0000
127+++ lib/lp/scripts/runlaunchpad.py 2018-01-02 08:22:55 +0000
128@@ -49,8 +49,7 @@
129 """
130 raise NotImplementedError
131
132- def setUp(self):
133- super(Service, self).setUp()
134+ def _setUp(self):
135 self.launch()
136
137
138
139=== modified file 'lib/lp/services/config/fixture.py'
140--- lib/lp/services/config/fixture.py 2016-10-11 15:28:25 +0000
141+++ lib/lp/services/config/fixture.py 2018-01-02 08:22:55 +0000
142@@ -48,8 +48,7 @@
143 if config.instance_name == self.instance_name:
144 config._invalidateConfig()
145
146- def setUp(self):
147- super(ConfigFixture, self).setUp()
148+ def _setUp(self):
149 root = os.path.join(config.root, 'configs', self.instance_name)
150 os.mkdir(root)
151 self.absroot = os.path.abspath(root)
152@@ -70,7 +69,6 @@
153 def __init__(self, instance_name):
154 self.instance_name = instance_name
155
156- def setUp(self):
157- super(ConfigUseFixture, self).setUp()
158+ def _setUp(self):
159 self.addCleanup(config.setInstance, config.instance_name)
160 config.setInstance(self.instance_name)
161
162=== modified file 'lib/lp/services/features/testing.py'
163--- lib/lp/services/features/testing.py 2014-02-26 00:45:07 +0000
164+++ lib/lp/services/features/testing.py 2018-01-02 08:22:55 +0000
165@@ -60,10 +60,8 @@
166 self.full_feature_rules = full_feature_rules
167 self.override_scope_lookup = override_scope_lookup
168
169- def setUp(self):
170+ def _setUp(self):
171 """Set the feature flags that this fixture is responsible for."""
172- super(FeatureFixtureMixin, self).setUp()
173-
174 rule_source = self.makeRuleSource(self.makeNewRules())
175
176 original_controller = get_relevant_feature_controller()
177
178=== modified file 'lib/lp/services/librarianserver/testing/fake.py'
179--- lib/lp/services/librarianserver/testing/fake.py 2016-04-02 01:33:35 +0000
180+++ lib/lp/services/librarianserver/testing/fake.py 2018-01-02 08:22:55 +0000
181@@ -70,9 +70,8 @@
182 utility.
183 """
184
185- def setUp(self):
186+ def _setUp(self):
187 """Fixture API: install as the librarian."""
188- Fixture.setUp(self)
189 self.aliases = {}
190 self.download_url = config.librarian.download_url
191 transaction.manager.registerSynch(self)
192
193=== modified file 'lib/lp/services/librarianserver/testing/tests/test_server_fixture.py'
194--- lib/lp/services/librarianserver/testing/tests/test_server_fixture.py 2012-04-16 23:02:44 +0000
195+++ lib/lp/services/librarianserver/testing/tests/test_server_fixture.py 2018-01-02 08:22:55 +0000
196@@ -28,7 +28,7 @@
197
198 def skip_if_persistent(self, fixture):
199 if fixture._persistent_servers():
200- self.skip('persistent server running.')
201+ self.skipTest('persistent server running.')
202
203 def test_on_init_no_pid(self):
204 fixture = LibrarianServerFixture(BaseLayer.config_fixture)
205
206=== modified file 'lib/lp/services/memcache/testing.py'
207--- lib/lp/services/memcache/testing.py 2016-09-07 03:43:36 +0000
208+++ lib/lp/services/memcache/testing.py 2018-01-02 08:22:55 +0000
209@@ -18,8 +18,7 @@
210 def __init__(self):
211 self._cache = {}
212
213- def setUp(self):
214- super(MemcacheFixture, self).setUp()
215+ def _setUp(self):
216 self.useFixture(ZopeUtilityFixture(self, IMemcacheClient))
217
218 def get(self, key):
219
220=== modified file 'lib/lp/services/utils.py'
221--- lib/lp/services/utils.py 2016-10-12 14:02:19 +0000
222+++ lib/lp/services/utils.py 2018-01-02 08:22:55 +0000
223@@ -257,8 +257,7 @@
224 self.stdout = StringIO()
225 self.stderr = StringIO()
226
227- def setUp(self):
228- super(CapturedOutput, self).setUp()
229+ def _setUp(self):
230 self.useFixture(MonkeyPatch('sys.stdout', self.stdout))
231 self.useFixture(MonkeyPatch('sys.stderr', self.stderr))
232
233
234=== modified file 'lib/lp/snappy/browser/tests/test_snap.py'
235--- lib/lp/snappy/browser/tests/test_snap.py 2017-10-20 13:35:42 +0000
236+++ lib/lp/snappy/browser/tests/test_snap.py 2018-01-02 08:22:55 +0000
237@@ -326,11 +326,11 @@
238 owner=self.person,
239 information_type=InformationType.USERDATA)
240
241- with self.useFixture(FeatureFixture({SNAP_PRIVATE_FEATURE_FLAG: ""})):
242+ with FeatureFixture({SNAP_PRIVATE_FEATURE_FLAG: ""}):
243 browser = self.getViewBrowser(branch, user=self.person)
244 self.assertRaises(
245 LinkNotFoundError, browser.getLink, "Create snap package")
246- with self.useFixture(FeatureFixture(SNAP_TESTING_FLAGS)):
247+ with FeatureFixture(SNAP_TESTING_FLAGS):
248 browser = self.getViewBrowser(branch, user=self.person)
249 browser.getLink("Create snap package")
250
251
252=== modified file 'lib/lp/testing/fixture.py'
253--- lib/lp/testing/fixture.py 2017-09-02 13:29:14 +0000
254+++ lib/lp/testing/fixture.py 2018-01-02 08:22:55 +0000
255@@ -156,8 +156,7 @@
256 def __init__(self, *args, **kwargs):
257 self._args, self._kwargs = args, kwargs
258
259- def setUp(self):
260- super(ZopeAdapterFixture, self).setUp()
261+ def _setUp(self):
262 site_manager = getGlobalSiteManager()
263 site_manager.registerAdapter(
264 *self._args, **self._kwargs)
265@@ -173,8 +172,7 @@
266 super(ZopeEventHandlerFixture, self).__init__()
267 self._handler = handler
268
269- def setUp(self):
270- super(ZopeEventHandlerFixture, self).setUp()
271+ def _setUp(self):
272 gsm = getGlobalSiteManager()
273 provideHandler(self._handler)
274 self.addCleanup(gsm.unregisterHandler, self._handler)
275@@ -207,8 +205,7 @@
276 'Try a layer.')
277 self.replacement = replacement
278
279- def setUp(self):
280- super(ZopeViewReplacementFixture, self).setUp()
281+ def _setUp(self):
282 if self.replacement is None:
283 raise ValueError('replacement is not set')
284 self.gsm.adapters.register(
285@@ -243,8 +240,7 @@
286 self.name = name
287 self.intf = intf
288
289- def setUp(self):
290- super(ZopeUtilityFixture, self).setUp()
291+ def _setUp(self):
292 gsm = getGlobalSiteManager()
293 original = gsm.queryUtility(self.intf, self.name)
294 gsm.registerUtility(self.component, self.intf, self.name)
295@@ -263,10 +259,9 @@
296 that is all that is needed. Later work could connect all
297 sub-hosts (e.g. bugs.launchpad.dev)."""
298
299- def setUp(self):
300+ def _setUp(self):
301 # Work around circular import.
302 from lp.testing.layers import wsgi_application
303- super(Urllib2Fixture, self).setUp()
304 add_wsgi_intercept('launchpad.dev', 80, lambda: wsgi_application)
305 self.addCleanup(remove_wsgi_intercept, 'launchpad.dev', 80)
306 install_opener()
307@@ -284,8 +279,7 @@
308
309 AMQP_SENTINEL = "STOP NOW"
310
311- def setUp(self):
312- super(CaptureOops, self).setUp()
313+ def _setUp(self):
314 self.oopses = []
315 self.oops_ids = set()
316 self.useFixture(ZopeEventHandlerFixture(self._recordOops))
317@@ -372,8 +366,7 @@
318 reset the timeline.
319 """
320
321- def setUp(self):
322- Fixture.setUp(self)
323+ def _setUp(self):
324 webapp.adapter.set_request_started(time.time())
325 self.timeline = get_request_timeline(
326 get_current_browser_request())
327@@ -387,8 +380,7 @@
328 other things.
329 """
330
331- def setUp(self):
332- Fixture.setUp(self)
333+ def _setUp(self):
334 config.push('demo-fixture', '''
335 [launchpad]
336 is_demo: true
337@@ -404,8 +396,7 @@
338 def __init__(self, table_triggers=None):
339 self.table_triggers = table_triggers or {}
340
341- def setUp(self):
342- super(DisableTriggerFixture, self).setUp()
343+ def _setUp(self):
344 self._disable_triggers()
345 self.addCleanup(self._enable_triggers)
346
347
348=== modified file 'lib/lp/testing/tests/test_layers_functional.py'
349--- lib/lp/testing/tests/test_layers_functional.py 2015-10-13 14:01:25 +0000
350+++ lib/lp/testing/tests/test_layers_functional.py 2018-01-02 08:22:55 +0000
351@@ -76,8 +76,7 @@
352 super(BaseLayerIsolator, self).__init__()
353 self.with_persistent = with_persistent
354
355- def setUp(self):
356- super(BaseLayerIsolator, self).setUp()
357+ def _setUp(self):
358 if self.with_persistent:
359 env_value = ''
360 else:
361@@ -103,8 +102,7 @@
362 super(LayerFixture, self).__init__()
363 self.layer = layer
364
365- def setUp(self):
366- super(LayerFixture, self).setUp()
367+ def _setUp(self):
368 self.layer.setUp()
369 self.addCleanup(self.layer.tearDown)
370
371
372=== modified file 'lib/lp/testing/tests/test_matchers.py'
373--- lib/lp/testing/tests/test_matchers.py 2017-11-04 23:21:54 +0000
374+++ lib/lp/testing/tests/test_matchers.py 2018-01-02 08:22:55 +0000
375@@ -376,7 +376,7 @@
376 matcher = EqualsIgnoringWhitespace("one \t two \n three")
377 mismatch = matcher.match(" one \r three ")
378 self.assertEqual(
379- "'one two three' != 'one three'",
380+ "'one three' != 'one two three'",
381 mismatch.describe())
382
383 def test_match_unicode(self):
384@@ -387,7 +387,7 @@
385 matcher = EqualsIgnoringWhitespace(u"one \t two \n \u1234 ")
386 mismatch = matcher.match(u" one \r \u1234 ")
387 self.assertEqual(
388- u"u'one two \\u1234' != u'one \\u1234'",
389+ u"u'one \\u1234' != u'one two \\u1234'",
390 mismatch.describe())
391
392 def test_match_non_string(self):