From a7450229f8358b8bd038d177e2b504554a98bd45 Mon Sep 17 00:00:00 2001 From: "ChangBo Guo(gcb)" Date: Wed, 2 Apr 2014 17:09:21 +0800 Subject: [PATCH] Trival:Fix assertEqual arguments order assertEqual method's arguments should be in ('expected', 'actual') order. Change-Id: I35f045a9d3a6e7f083fb137c751eeab52c77000b Closes-bug: 1277104 --- tests/test_exception_serialization.py | 22 +++++++-------- tests/test_executor.py | 24 ++++++++-------- tests/test_notifier.py | 10 +++---- tests/test_notifier_logger.py | 24 ++++++++-------- tests/test_notify_dispatcher.py | 20 +++++++------- tests/test_notify_listener.py | 2 +- tests/test_pool.py | 2 +- tests/test_qpid.py | 8 +++--- tests/test_rabbit.py | 30 ++++++++++---------- tests/test_rpc_client.py | 4 +-- tests/test_rpc_dispatcher.py | 12 ++++---- tests/test_rpc_server.py | 40 +++++++++++++-------------- tests/test_target.py | 6 ++-- tests/test_transport.py | 2 +- tests/test_urls.py | 4 +-- 15 files changed, 105 insertions(+), 105 deletions(-) diff --git a/tests/test_exception_serialization.py b/tests/test_exception_serialization.py index 5fed251f6..2665b5ef7 100644 --- a/tests/test_exception_serialization.py +++ b/tests/test_exception_serialization.py @@ -133,11 +133,11 @@ class SerializeRemoteExceptionTestCase(test_utils.BaseTestCase): failure = jsonutils.loads(serialized) - self.assertEqual(failure['class'], self.clsname, failure) - self.assertEqual(failure['module'], self.modname) - self.assertEqual(failure['message'], self.msg) - self.assertEqual(failure['args'], [self.msg]) - self.assertEqual(failure['kwargs'], self.kwargs) + self.assertEqual(self.clsname, failure['class'], failure) + self.assertEqual(self.modname, failure['module']) + self.assertEqual(self.msg, failure['message']) + self.assertEqual([self.msg], failure['args']) + self.assertEqual(self.kwargs, failure['kwargs']) # Note: _Remote prefix not stripped from tracebacks tb = cls_error.__class__.__name__ + ': ' + self.msg @@ -146,7 +146,7 @@ class SerializeRemoteExceptionTestCase(test_utils.BaseTestCase): if self.log_failure: self.assertTrue(len(errors) > 0, errors) else: - self.assertEqual(len(errors), 0, errors) + self.assertEqual(0, len(errors), errors) SerializeRemoteExceptionTestCase.generate_scenarios() @@ -298,10 +298,10 @@ class DeserializeRemoteExceptionTestCase(test_utils.BaseTestCase): ex = exceptions.deserialize_remote_exception(serialized, self.allowed) self.assertIsInstance(ex, self.cls) - self.assertEqual(ex.__class__.__name__, self.remote_name) - self.assertEqual(six.text_type(ex), self.str) + self.assertEqual(self.remote_name, ex.__class__.__name__) + self.assertEqual(self.str, six.text_type(ex)) if hasattr(self, 'msg'): - self.assertEqual(six.text_type(ex), self.msg) - self.assertEqual(ex.args, (self.msg,) + self.remote_args) + self.assertEqual(self.msg, six.text_type(ex)) + self.assertEqual((self.msg,) + self.remote_args, ex.args) else: - self.assertEqual(ex.args, self.remote_args) + self.assertEqual(self.remote_args, ex.args) diff --git a/tests/test_executor.py b/tests/test_executor.py index 509ad0c9d..26f642e27 100644 --- a/tests/test_executor.py +++ b/tests/test_executor.py @@ -107,10 +107,10 @@ class EventletContextManagerSpawnTest(test_utils.BaseTestCase): def test_normal_run(self): thread = impl_eventlet.spawn_with(self.mgr, pool=eventlet) thread.wait() - self.assertEqual(self.before.call_count, 1) - self.assertEqual(self.callback.call_count, 1) - self.assertEqual(self.after.call_count, 1) - self.assertEqual(self.exception_call.call_count, 0) + self.assertEqual(1, self.before.call_count) + self.assertEqual(1, self.callback.call_count) + self.assertEqual(1, self.after.call_count) + self.assertEqual(0, self.exception_call.call_count) def test_excepted_exception(self): self.callback.side_effect = ExceptedException @@ -119,10 +119,10 @@ class EventletContextManagerSpawnTest(test_utils.BaseTestCase): thread.wait() except ExceptedException: pass - self.assertEqual(self.before.call_count, 1) - self.assertEqual(self.callback.call_count, 1) - self.assertEqual(self.after.call_count, 1) - self.assertEqual(self.exception_call.call_count, 1) + self.assertEqual(1, self.before.call_count) + self.assertEqual(1, self.callback.call_count) + self.assertEqual(1, self.after.call_count) + self.assertEqual(1, self.exception_call.call_count) def test_unexcepted_exception(self): self.callback.side_effect = Exception @@ -131,7 +131,7 @@ class EventletContextManagerSpawnTest(test_utils.BaseTestCase): thread.wait() except Exception: pass - self.assertEqual(self.before.call_count, 1) - self.assertEqual(self.callback.call_count, 1) - self.assertEqual(self.after.call_count, 0) - self.assertEqual(self.exception_call.call_count, 0) + self.assertEqual(1, self.before.call_count) + self.assertEqual(1, self.callback.call_count) + self.assertEqual(0, self.after.call_count) + self.assertEqual(0, self.exception_call.call_count) diff --git a/tests/test_notifier.py b/tests/test_notifier.py index 40733c0fa..802211247 100644 --- a/tests/test_notifier.py +++ b/tests/test_notifier.py @@ -243,8 +243,8 @@ class TestSerializer(test_utils.BaseTestCase): 'timestamp': str(timeutils.utcnow()), } - self.assertEqual(_impl_test.NOTIFICATIONS, - [(dict(user='alice'), message, 'INFO')]) + self.assertEqual([(dict(user='alice'), message, 'INFO')], + _impl_test.NOTIFICATIONS) class TestLogNotifier(test_utils.BaseTestCase): @@ -324,7 +324,7 @@ class TestRoutingNotifier(test_utils.BaseTestCase): def test_load_notifiers_no_config(self): # default routing_notifier_config="" self.router._load_notifiers() - self.assertEqual(self.router.routing_groups, {}) + self.assertEqual({}, self.router.routing_groups) self.assertEqual(0, len(self.router.used_drivers)) def test_load_notifiers_no_extensions(self): @@ -341,7 +341,7 @@ class TestRoutingNotifier(test_utils.BaseTestCase): '_impl_routing.LOG') as mylog: self.router._load_notifiers() self.assertFalse(mylog.debug.called) - self.assertEqual(self.router.routing_groups, {}) + self.assertEqual({}, self.router.routing_groups) def test_load_notifiers_config(self): self.config(routing_notifier_config="routing_notifier.yaml") @@ -478,4 +478,4 @@ group_1: with mock.patch.object(self.router, '_get_drivers_for_message', drivers_mock): self.router.notify({}, message) - self.assertEqual(pm.map.call_args[0][4], ['rpc', 'foo']) + self.assertEqual(['rpc', 'foo'], pm.map.call_args[0][4]) diff --git a/tests/test_notifier_logger.py b/tests/test_notifier_logger.py index 708cc95da..ac4a77058 100644 --- a/tests/test_notifier_logger.py +++ b/tests/test_notifier_logger.py @@ -84,13 +84,12 @@ class TestLogNotifier(test_utils.BaseTestCase): self.logger.emit(record) n = messaging.notify._impl_test.NOTIFICATIONS[0][1] - self.assertEqual(n['priority'], - getattr(self, 'queue', self.priority.upper())) - self.assertEqual(n['event_type'], 'logrecord') - self.assertEqual(n['timestamp'], str(timeutils.utcnow())) - self.assertEqual(n['publisher_id'], None) + self.assertEqual(getattr(self, 'queue', self.priority.upper()), + n['priority']) + self.assertEqual('logrecord', n['event_type']) + self.assertEqual(str(timeutils.utcnow()), n['timestamp']) + self.assertEqual(None, n['publisher_id']) self.assertEqual( - n['payload'], {'process': os.getpid(), 'funcName': None, 'name': 'foo', @@ -102,7 +101,8 @@ class TestLogNotifier(test_utils.BaseTestCase): 'msg': 'Something happened', 'exc_info': None, 'levelname': logging.getLevelName(levelno), - 'extra': None}) + 'extra': None}, + n['payload']) @testtools.skipUnless(hasattr(logging.config, 'dictConfig'), "Need logging.config.dictConfig (Python >= 2.7)") @@ -136,11 +136,11 @@ class TestLogNotifier(test_utils.BaseTestCase): logger.log(levelno, 'foobar') n = messaging.notify._impl_test.NOTIFICATIONS[0][1] - self.assertEqual(n['priority'], - getattr(self, 'queue', self.priority.upper())) - self.assertEqual(n['event_type'], 'logrecord') - self.assertEqual(n['timestamp'], str(timeutils.utcnow())) - self.assertEqual(n['publisher_id'], None) + self.assertEqual(getattr(self, 'queue', self.priority.upper()), + n['priority']) + self.assertEqual('logrecord', n['event_type']) + self.assertEqual(str(timeutils.utcnow()), n['timestamp']) + self.assertEqual(None, n['publisher_id']) pathname = __file__ if pathname.endswith(('.pyc', '.pyo')): pathname = pathname[:-1] diff --git a/tests/test_notify_dispatcher.py b/tests/test_notify_dispatcher.py index a1cfc7b28..9e982992b 100644 --- a/tests/test_notify_dispatcher.py +++ b/tests/test_notify_dispatcher.py @@ -101,10 +101,10 @@ class TestDispatcher(test_utils.BaseTestCase): targets, endpoints, None, allow_requeue=True) # check it listen on wanted topics - self.assertEqual(sorted(dispatcher._targets_priorities), - sorted(set((targets[0], prio) + self.assertEqual(sorted(set((targets[0], prio) for prio in itertools.chain.from_iterable( - self.endpoints)))) + self.endpoints))), + sorted(dispatcher._targets_priorities)) incoming = mock.Mock(ctxt={}, message=msg) with dispatcher(incoming) as callback: @@ -123,18 +123,18 @@ class TestDispatcher(test_utils.BaseTestCase): })] self.assertEqual(method.call_args_list, expected) else: - self.assertEqual(endpoints[i].call_count, 0) + self.assertEqual(0, endpoints[i].call_count) if self.ex: - self.assertEqual(incoming.acknowledge.call_count, 1) - self.assertEqual(incoming.requeue.call_count, 0) + self.assertEqual(1, incoming.acknowledge.call_count) + self.assertEqual(0, incoming.requeue.call_count) elif self.return_value == messaging.NotificationResult.HANDLED \ or self.return_value is None: - self.assertEqual(incoming.acknowledge.call_count, 1) - self.assertEqual(incoming.requeue.call_count, 0) + self.assertEqual(1, incoming.acknowledge.call_count) + self.assertEqual(0, incoming.requeue.call_count) elif self.return_value == messaging.NotificationResult.REQUEUE: - self.assertEqual(incoming.acknowledge.call_count, 0) - self.assertEqual(incoming.requeue.call_count, 1) + self.assertEqual(0, incoming.acknowledge.call_count) + self.assertEqual(1, incoming.requeue.call_count) @mock.patch('oslo.messaging.notify.dispatcher.LOG') def test_dispatcher_unknown_prio(self, mylog): diff --git a/tests/test_notify_listener.py b/tests/test_notify_listener.py index 9b13bf4a3..608191598 100644 --- a/tests/test_notify_listener.py +++ b/tests/test_notify_listener.py @@ -114,7 +114,7 @@ class TestNotifyListener(test_utils.BaseTestCase, ListenerSetupMixin): executor='foo') except Exception as ex: self.assertIsInstance(ex, messaging.ExecutorLoadFailure) - self.assertEqual(ex.executor, 'foo') + self.assertEqual('foo', ex.executor) else: self.assertTrue(False) diff --git a/tests/test_pool.py b/tests/test_pool.py index 768a766a4..e068f84a9 100644 --- a/tests/test_pool.py +++ b/tests/test_pool.py @@ -118,7 +118,7 @@ class PoolTestCase(test_utils.BaseTestCase): self.assertIn(o, objs) objs.remove(o) - self.assertEqual(objs, []) + self.assertEqual([], objs) PoolTestCase.generate_scenarios() diff --git a/tests/test_qpid.py b/tests/test_qpid.py index 96a3c46e3..e1b0e8ccf 100644 --- a/tests/test_qpid.py +++ b/tests/test_qpid.py @@ -213,8 +213,8 @@ class TestQpidDirectConsumerPublisher(_QpidBaseTestCase): thread1.join() thread2.join() - self.assertEqual(len(self._messages), self.no_msgs) - self.assertEqual(self._messages, self._expected) + self.assertEqual(self.no_msgs, len(self._messages)) + self.assertEqual(self._expected, self._messages) TestQpidDirectConsumerPublisher.generate_scenarios() @@ -381,8 +381,8 @@ class TestQpidTopicAndFanout(_QpidBaseTestCase): # self._messages and compare with the expected messages # messages. - self.assertEqual(len(self._expected), self.no_senders) - self.assertEqual(len(self._messages), self.no_receivers) + self.assertEqual(self.no_senders, len(self._expected)) + self.assertEqual(self.no_receivers, len(self._messages)) for key, messages in self._messages.iteritems(): self.assertEqual(self._expected, messages) diff --git a/tests/test_rabbit.py b/tests/test_rabbit.py index 39afb3ca4..148e16d1a 100644 --- a/tests/test_rabbit.py +++ b/tests/test_rabbit.py @@ -104,16 +104,16 @@ class TestRabbitTransportURL(test_utils.BaseTestCase): def test_transport_url_listen(self): self._driver.listen(self._target) - self.assertEqual(self._server_params[0], self.expected) + self.assertEqual(self.expected, self._server_params[0]) def test_transport_url_listen_for_notification(self): self._driver.listen_for_notifications( [(messaging.Target(topic='topic'), 'info')]) - self.assertEqual(self._server_params[0], self.expected) + self.assertEqual(self.expected, self._server_params[0]) def test_transport_url_send(self): self._driver.send(self._target, {}, {}) - self.assertEqual(self._server_params[0], self.expected) + self.assertEqual(self.expected, self._server_params[0]) class TestSendReceive(test_utils.BaseTestCase): @@ -205,8 +205,8 @@ class TestSendReceive(test_utils.BaseTestCase): received = listener.poll() self.assertIsNotNone(received) - self.assertEqual(received.ctxt, self.ctxt) - self.assertEqual(received.message, {'tx_id': i}) + self.assertEqual(self.ctxt, received.ctxt) + self.assertEqual({'tx_id': i}, received.message) msgs.append(received) # reply in reverse, except reply to the first guy second from last @@ -229,21 +229,21 @@ class TestSendReceive(test_utils.BaseTestCase): msgs[i].reply(self.reply) senders[i].join() - self.assertEqual(len(replies), len(senders)) + self.assertEqual(len(senders), len(replies)) for i, reply in enumerate(replies): if self.timeout is not None: self.assertIsInstance(reply, messaging.MessagingTimeout) elif self.failure: self.assertIsInstance(reply, ZeroDivisionError) elif self.rx_id: - self.assertEqual(reply, {'rx_id': order[i]}) + self.assertEqual({'rx_id': order[i]}, reply) else: - self.assertEqual(reply, self.reply) + self.assertEqual(self.reply, reply) if not self.timeout and self.failure and not self.expected: self.assertTrue(len(errors) > 0, errors) else: - self.assertEqual(len(errors), 0, errors) + self.assertEqual(0, len(errors), errors) TestSendReceive.generate_scenarios() @@ -300,13 +300,13 @@ class TestRacyWaitForReply(test_utils.BaseTestCase): senders[0].start() msgs.append(listener.poll()) - self.assertEqual(msgs[-1].message, {'tx_id': 0}) + self.assertEqual({'tx_id': 0}, msgs[-1].message) # Start the second guy, receive his message senders[1].start() msgs.append(listener.poll()) - self.assertEqual(msgs[-1].message, {'tx_id': 1}) + self.assertEqual({'tx_id': 1}, msgs[-1].message) # Reply to both in order, making the second thread queue # the reply meant for the first thread @@ -324,9 +324,9 @@ class TestRacyWaitForReply(test_utils.BaseTestCase): senders[0].join() # Verify replies were received out of order - self.assertEqual(len(replies), len(senders)) - self.assertEqual(replies[0], {'rx_id': 1}) - self.assertEqual(replies[1], {'rx_id': 0}) + self.assertEqual(len(senders), len(replies)) + self.assertEqual({'rx_id': 1}, replies[0]) + self.assertEqual({'rx_id': 0}, replies[1]) def _declare_queue(target): @@ -625,7 +625,7 @@ class RpcKombuHATestCase(test_utils.BaseTestCase): myself.connection_errors = myself.connection.connection_errors expected_broker = brokers[info['attempt'] % brokers_count] - self.assertEqual(params['hostname'], expected_broker) + self.assertEqual(expected_broker, params['hostname']) info['attempt'] += 1 diff --git a/tests/test_rpc_client.py b/tests/test_rpc_client.py index 3a1462190..c42a3455d 100644 --- a/tests/test_rpc_client.py +++ b/tests/test_rpc_client.py @@ -305,7 +305,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.assertEqual(retval, 'd' + self.retval) + self.assertEqual('d' + self.retval, retval) class TestVersionCap(test_utils.BaseTestCase): @@ -464,4 +464,4 @@ class TestCanSendVersion(test_utils.BaseTestCase): else: can_send = client.can_send_version() - self.assertEqual(can_send, self.can_send) + self.assertEqual(self.can_send, can_send) diff --git a/tests/test_rpc_dispatcher.py b/tests/test_rpc_dispatcher.py index 8d12278a2..0b24c6334 100644 --- a/tests/test_rpc_dispatcher.py +++ b/tests/test_rpc_dispatcher.py @@ -107,10 +107,10 @@ class TestDispatcher(test_utils.BaseTestCase): self.assertIsNotNone(self.ex, ex) self.assertIsInstance(ex, self.ex, ex) if isinstance(ex, messaging.NoSuchMethod): - self.assertEqual(ex.method, self.msg.get('method')) + self.assertEqual(self.msg.get('method'), ex.method) elif isinstance(ex, messaging.UnsupportedVersion): - self.assertEqual(ex.version, - self.msg.get('version', '1.0')) + self.assertEqual(self.msg.get('version', '1.0'), + ex.version) else: self.assertTrue(self.success, failure) self.assertIsNone(failure) @@ -129,9 +129,9 @@ class TestDispatcher(test_utils.BaseTestCase): method.assert_called_once_with( self.ctxt, **self.msg.get('args', {})) else: - self.assertEqual(method.call_count, 0) + self.assertEqual(0, method.call_count) - self.assertEqual(incoming.reply.call_count, 1) + self.assertEqual(1, incoming.reply.call_count) class TestSerializer(test_utils.BaseTestCase): @@ -173,4 +173,4 @@ class TestSerializer(test_utils.BaseTestCase): retval = dispatcher._dispatch(self.ctxt, dict(method='foo', args=self.args)) if self.retval is not None: - self.assertEqual(retval, 's' + self.retval) + self.assertEqual('s' + self.retval, retval) diff --git a/tests/test_rpc_server.py b/tests/test_rpc_server.py index 1f2df2a13..5a1308154 100644 --- a/tests/test_rpc_server.py +++ b/tests/test_rpc_server.py @@ -120,7 +120,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): server.start() except Exception as ex: self.assertIsInstance(ex, messaging.InvalidTarget, ex) - self.assertEqual(ex.target.topic, 'testtopic') + self.assertEqual('testtopic', ex.target.topic) else: self.assertTrue(False) @@ -132,7 +132,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): server.start() except Exception as ex: self.assertIsInstance(ex, messaging.InvalidTarget, ex) - self.assertEqual(ex.target.server, 'testserver') + self.assertEqual('testserver', ex.target.server) else: self.assertTrue(False) @@ -192,7 +192,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): messaging.get_rpc_server(transport, None, [], executor='foo') except Exception as ex: self.assertIsInstance(ex, messaging.ExecutorLoadFailure) - self.assertEqual(ex.executor, 'foo') + self.assertEqual('foo', ex.executor) else: self.assertTrue(False) @@ -215,7 +215,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): self._stop_server(client, server_thread) - self.assertEqual(endpoint.pings, ['dsfoo', 'dsbar']) + self.assertEqual(['dsfoo', 'dsbar'], endpoint.pings) def test_call(self): transport = messaging.get_transport(self.conf, url='fake:') @@ -228,11 +228,11 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): client = self._setup_client(transport) self.assertIsNone(client.call({}, 'ping', arg=None)) - self.assertEqual(client.call({}, 'ping', arg=0), 0) - self.assertEqual(client.call({}, 'ping', arg=False), False) - self.assertEqual(client.call({}, 'ping', arg=[]), []) - self.assertEqual(client.call({}, 'ping', arg={}), {}) - self.assertEqual(client.call({}, 'ping', arg='foo'), 'dsdsfoo') + self.assertEqual(0, client.call({}, 'ping', arg=0)) + self.assertEqual(False, client.call({}, 'ping', arg=False)) + self.assertEqual([], client.call({}, 'ping', arg=[])) + self.assertEqual({}, client.call({}, 'ping', arg={})) + self.assertEqual('dsdsfoo', client.call({}, 'ping', arg='foo')) self._stop_server(client, server_thread) @@ -248,11 +248,11 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): direct = client.prepare(server='testserver') self.assertIsNone(direct.call({}, 'ping', arg=None)) - self.assertEqual(client.call({}, 'ping', arg=0), 0) - self.assertEqual(client.call({}, 'ping', arg=False), False) - self.assertEqual(client.call({}, 'ping', arg=[]), []) - self.assertEqual(client.call({}, 'ping', arg={}), {}) - self.assertEqual(direct.call({}, 'ping', arg='foo'), 'dsdsfoo') + self.assertEqual(0, client.call({}, 'ping', arg=0)) + self.assertEqual(False, client.call({}, 'ping', arg=False)) + self.assertEqual([], client.call({}, 'ping', arg=[])) + self.assertEqual({}, client.call({}, 'ping', arg={})) + self.assertEqual('dsdsfoo', direct.call({}, 'ping', arg='foo')) self._stop_server(client, server_thread) @@ -266,10 +266,10 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): server_thread = self._setup_server(transport, TestEndpoint()) client = self._setup_client(transport) - self.assertEqual(client.call({'dsa': 'b'}, + self.assertEqual('dsdsb', + client.call({'dsa': 'b'}, 'ctxt_check', - key='a'), - 'dsdsb') + key='a')) self._stop_server(client, server_thread) @@ -287,7 +287,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): client.call({}, 'ping', arg='foo') except Exception as ex: self.assertIsInstance(ex, ValueError) - self.assertEqual(ex[0], 'dsfoo') + self.assertEqual('dsfoo', ex[0]) else: self.assertTrue(False) @@ -308,7 +308,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin): client.call({}, 'ping', arg='foo') except Exception as ex: self.assertIsInstance(ex, ValueError) - self.assertEqual(ex[0], 'dsfoo') + self.assertEqual('dsfoo', ex[0]) else: self.assertTrue(False) @@ -469,7 +469,7 @@ class TestMultipleServers(test_utils.BaseTestCase, ServerSetupMixin): thread2, topic=self.topic2) def check(pings, expect): - self.assertEqual(len(pings), len(expect)) + self.assertEqual(len(expect), len(pings)) for a in expect: self.assertIn(a, pings) diff --git a/tests/test_target.py b/tests/test_target.py index a7d640451..bdf857034 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.assertEqual(getattr(target, k), self.kwargs[k]) + self.assertEqual(self.kwargs[k], getattr(target, 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.assertEqual(getattr(target, k), self.vals[k]) + self.assertEqual(self.vals[k], getattr(target, 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.assertEqual(str(target), '') + self.assertEqual('', str(target)) _notset = object() diff --git a/tests/test_transport.py b/tests/test_transport.py index ac30ce41d..fda747372 100644 --- a/tests/test_transport.py +++ b/tests/test_transport.py @@ -202,7 +202,7 @@ class GetTransportSadPathTestCase(test_utils.BaseTestCase): for k, v in self.ex.items(): self.assertTrue(hasattr(ex, k)) - self.assertEqual(str(getattr(ex, k)), v) + self.assertEqual(v, str(getattr(ex, k))) # FIXME(markmc): this could be used elsewhere diff --git a/tests/test_urls.py b/tests/test_urls.py index 61e43548a..c35dad34c 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -134,7 +134,7 @@ class TestParseURL(test_utils.BaseTestCase): self.expect.get('virtual_host'), hosts) - self.assertEqual(url, expected) + self.assertEqual(expected, url) class TestFormatURL(test_utils.BaseTestCase): @@ -233,4 +233,4 @@ class TestFormatURL(test_utils.BaseTestCase): hosts, self.aliases) - self.assertEqual(str(url), self.expected) + self.assertEqual(self.expected, str(url))