From d31ae442cae88d710c06b501b66e7b205b820480 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Mon, 17 Jun 2013 23:01:21 +0100 Subject: [PATCH] Use assertEqual() rather than assertEquals() assertEquals() is deprecated: http://docs.python.org/2/library/unittest.html#deprecated-aliases --- tests/test_rpc_client.py | 8 ++++---- tests/test_rpc_dispatcher.py | 6 +++--- tests/test_rpc_server.py | 22 +++++++++++----------- tests/test_target.py | 8 ++++---- tests/test_transport.py | 2 +- tests/test_urls.py | 6 +++--- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/test_rpc_client.py b/tests/test_rpc_client.py index fcf8bb140..9717e2041 100644 --- a/tests/test_rpc_client.py +++ b/tests/test_rpc_client.py @@ -313,7 +313,7 @@ class TestSerializer(test_utils.BaseTestCase): method = client.call if self.call else client.cast retval = method(self.ctxt, 'foo', **self.args) if self.retval is not None: - self.assertEquals(retval, 'd' + self.retval) + self.assertEqual(retval, 'd' + self.retval) class TestVersionCap(test_utils.BaseTestCase): @@ -480,7 +480,7 @@ class TestCanSendVersion(test_utils.BaseTestCase): else: can_send = client.can_send_version() - self.assertEquals(can_send, self.can_send) + self.assertEqual(can_send, self.can_send) class TestCheckForLock(test_utils.BaseTestCase): @@ -528,7 +528,7 @@ class TestCheckForLock(test_utils.BaseTestCase): client.call({}, 'foo') if self.warning: - self.assertEquals(len(warnings), 1) + self.assertEqual(len(warnings), 1) self.assertTrue(self.warning in warnings[0]) else: - self.assertEquals(len(warnings), 0) + self.assertEqual(len(warnings), 0) diff --git a/tests/test_rpc_dispatcher.py b/tests/test_rpc_dispatcher.py index def2186f3..49ba348a0 100644 --- a/tests/test_rpc_dispatcher.py +++ b/tests/test_rpc_dispatcher.py @@ -117,9 +117,9 @@ class TestDispatcher(test_utils.BaseTestCase): self.assertTrue(self.ex is not None, ex) self.assertTrue(isinstance(ex, self.ex), ex) if isinstance(ex, messaging.NoSuchMethod): - self.assertEquals(ex.method, self.msg.get('method')) + self.assertEqual(ex.method, self.msg.get('method')) elif isinstance(ex, messaging.UnsupportedVersion): - self.assertEquals(ex.version, self.msg.get('version', '1.0')) + self.assertEqual(ex.version, self.msg.get('version', '1.0')) else: self.assertTrue(self.success) @@ -157,4 +157,4 @@ class TestSerializer(test_utils.BaseTestCase): retval = dispatcher(self.ctxt, dict(method='foo', args=self.args)) if self.retval is not None: - self.assertEquals(retval, 's' + self.retval) + self.assertEqual(retval, 's' + self.retval) diff --git a/tests/test_rpc_server.py b/tests/test_rpc_server.py index 5c0f6b9fe..3aefbcf16 100644 --- a/tests/test_rpc_server.py +++ b/tests/test_rpc_server.py @@ -115,7 +115,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): server.start() except Exception as ex: self.assertTrue(isinstance(ex, messaging.ServerListenError), ex) - self.assertEquals(ex.target.topic, 'testtopic') + self.assertEqual(ex.target.topic, 'testtopic') else: self.assertTrue(False) @@ -127,7 +127,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): server.start() except Exception as ex: self.assertTrue(isinstance(ex, messaging.ServerListenError), ex) - self.assertEquals(ex.target.server, 'testserver') + self.assertEqual(ex.target.server, 'testserver') else: self.assertTrue(False) @@ -187,7 +187,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): messaging.get_rpc_server(transport, None, [], executor='foo') except Exception as ex: self.assertTrue(isinstance(ex, messaging.ExecutorLoadFailure)) - self.assertEquals(ex.executor, 'foo') + self.assertEqual(ex.executor, 'foo') else: self.assertTrue(False) @@ -210,7 +210,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): self._stop_server(client, server_thread) - self.assertEquals(endpoint.pings, ['dsfoo', 'dsbar']) + self.assertEqual(endpoint.pings, ['dsfoo', 'dsbar']) def test_call(self): transport = messaging.get_transport(self.conf, url='fake:') @@ -222,7 +222,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): server_thread = self._setup_server(transport, TestEndpoint()) client = self._setup_client(transport) - self.assertEquals(client.call({}, 'ping', arg='foo'), 'dsdsfoo') + self.assertEqual(client.call({}, 'ping', arg='foo'), 'dsdsfoo') self._stop_server(client, server_thread) @@ -237,7 +237,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): client = self._setup_client(transport) direct = client.prepare(server='testserver') - self.assertEquals(direct.call({}, 'ping', arg='foo'), 'dsdsfoo') + self.assertEqual(direct.call({}, 'ping', arg='foo'), 'dsdsfoo') self._stop_server(client, server_thread) @@ -251,10 +251,10 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): server_thread = self._setup_server(transport, TestEndpoint()) client = self._setup_client(transport) - self.assertEquals(client.call({'dsa': 'b'}, - 'ctxt_check', - key='a'), - 'dsb') + self.assertEqual(client.call({'dsa': 'b'}, + 'ctxt_check', + key='a'), + 'dsb') self._stop_server(client, server_thread) @@ -413,7 +413,7 @@ class TestMultipleServers(test_utils.BaseTestCase, ServerSetupMixin): thread2, topic=self.topic2) def check(pings, expect): - self.assertEquals(len(pings), len(expect)) + self.assertEqual(len(pings), len(expect)) for a in expect: self.assertTrue(a in pings) diff --git a/tests/test_target.py b/tests/test_target.py index efe223c70..b5ae24067 100644 --- a/tests/test_target.py +++ b/tests/test_target.py @@ -36,7 +36,7 @@ class TargetConstructorTestCase(test_utils.BaseTestCase): def test_constructor(self): target = messaging.Target(**self.kwargs) for k in self.kwargs: - self.assertEquals(getattr(target, k), self.kwargs[k]) + self.assertEqual(getattr(target, k), self.kwargs[k]) for k in ['exchange', 'topic', 'namespace', 'version', 'server', 'fanout']: if k in self.kwargs: @@ -90,7 +90,7 @@ class TargetCallableTestCase(test_utils.BaseTestCase): target = messaging.Target(**self.attrs) target = target(**self.kwargs) for k in self.vals: - self.assertEquals(getattr(target, k), self.vals[k]) + self.assertEqual(getattr(target, k), self.vals[k]) for k in ['exchange', 'topic', 'namespace', 'version', 'server', 'fanout']: if k in self.vals: @@ -122,7 +122,7 @@ class TargetReprTestCase(test_utils.BaseTestCase): def test_repr(self): target = messaging.Target(**self.kwargs) - self.assertEquals(str(target), '') + self.assertEqual(str(target), '') _notset = object() @@ -167,7 +167,7 @@ class EqualityTestCase(test_utils.BaseTestCase): b = messaging.Target(**b_kwargs) if self.equals: - self.assertEquals(a, b) + self.assertEqual(a, b) self.assertFalse(a != b) else: self.assertNotEquals(a, b) diff --git a/tests/test_transport.py b/tests/test_transport.py index 893d55de9..cf2f9ca95 100644 --- a/tests/test_transport.py +++ b/tests/test_transport.py @@ -171,7 +171,7 @@ class GetTransportSadPathTestCase(test_utils.BaseTestCase): for k, v in self.ex.items(): self.assertTrue(hasattr(ex, k)) - self.assertEquals(getattr(ex, k), v) + self.assertEqual(getattr(ex, k), v) # FIXME(markmc): this could be used elsewhere diff --git a/tests/test_urls.py b/tests/test_urls.py index 7ca0d3813..2bb8a0c5d 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -52,8 +52,8 @@ class TestExchangeFromURL(test_utils.BaseTestCase): if self.default is not self._notset: kwargs['default_exchange'] = self.default - self.assertEquals(urls.exchange_from_url(self.url, **kwargs), - self.expect) + self.assertEqual(urls.exchange_from_url(self.url, **kwargs), + self.expect) class TestParseURL(test_utils.BaseTestCase): @@ -155,4 +155,4 @@ class TestParseURL(test_utils.BaseTestCase): ] def test_parse_url(self): - self.assertEquals(urls.parse_url(self.url), self.expect) + self.assertEqual(urls.parse_url(self.url), self.expect)