diff --git a/oslo_messaging/_cmd/__init__.py b/oslo_messaging/_cmd/__init__.py index 8b1378917..e69de29bb 100644 --- a/oslo_messaging/_cmd/__init__.py +++ b/oslo_messaging/_cmd/__init__.py @@ -1 +0,0 @@ - diff --git a/oslo_messaging/_drivers/__init__.py b/oslo_messaging/_drivers/__init__.py index 8b1378917..e69de29bb 100644 --- a/oslo_messaging/_drivers/__init__.py +++ b/oslo_messaging/_drivers/__init__.py @@ -1 +0,0 @@ - diff --git a/oslo_messaging/tests/drivers/pika/test_message.py b/oslo_messaging/tests/drivers/pika/test_message.py index 3c3f87e39..1a317db92 100644 --- a/oslo_messaging/tests/drivers/pika/test_message.py +++ b/oslo_messaging/tests/drivers/pika/test_message.py @@ -62,7 +62,7 @@ class PikaIncomingMessageTestCase(unittest.TestCase): message.acknowledge() - self.assertEqual(1, self._channel.basic_ack.call_count) + self.assertEqual(1, self._channel.basic_ack.call_count) self.assertEqual({"delivery_tag": self._delivery_tag}, self._channel.basic_ack.call_args[1]) @@ -74,7 +74,7 @@ class PikaIncomingMessageTestCase(unittest.TestCase): message.acknowledge() - self.assertEqual(0, self._channel.basic_ack.call_count) + self.assertEqual(0, self._channel.basic_ack.call_count) def test_message_requeue(self): message = pika_drv_msg.PikaIncomingMessage( @@ -574,7 +574,7 @@ class RpcReplyPikaOutgoingMessageTestCase(unittest.TestCase): self.assertIsNone(props.reply_to) self.assertTrue(props.message_id) - @patch("traceback.format_exception", new=lambda x,y,z:z) + @patch("traceback.format_exception", new=lambda x, y, z: z) @patch("oslo_serialization.jsonutils.dumps", new=functools.partial(jsonutils.dumps, sort_keys=True)) def test_failure_message_send(self): @@ -582,7 +582,6 @@ class RpcReplyPikaOutgoingMessageTestCase(unittest.TestCase): oslo_messaging.MessagingException("Error message"), ['It is a trace']) - message = pika_drv_msg.RpcReplyPikaOutgoingMessage( self._pika_engine, self._msg_id, failure_info=failure_info ) diff --git a/oslo_messaging/tests/drivers/pika/test_poller.py b/oslo_messaging/tests/drivers/pika/test_poller.py index 77a3b6b29..4455f9d7b 100644 --- a/oslo_messaging/tests/drivers/pika/test_poller.py +++ b/oslo_messaging/tests/drivers/pika/test_poller.py @@ -107,17 +107,17 @@ class PikaPollerTestCase(unittest.TestCase): res2 = poller.poll(prefetch_size=n) - self.assertEqual(len(res2), n-1) + self.assertEqual(len(res2), n - 1) self.assertEqual(incoming_message_class_mock.call_count, n) self.assertEqual( self._poller_connection_mock.process_data_events.call_count, 1) - for i in range(n-1): + for i in range(n - 1): self.assertEqual(res2[i], incoming_message_class_mock.return_value) self.assertEqual( - incoming_message_class_mock.call_args_list[i+1][0], - (self._pika_engine, None) + params[i+1][1:] + incoming_message_class_mock.call_args_list[i + 1][0], + (self._pika_engine, None) + params[i + 1][1:] ) self.assertTrue(self._pika_engine.create_connection.called) diff --git a/oslo_messaging/tests/drivers/test_impl_rabbit.py b/oslo_messaging/tests/drivers/test_impl_rabbit.py index 7d14d2857..676c81f41 100644 --- a/oslo_messaging/tests/drivers/test_impl_rabbit.py +++ b/oslo_messaging/tests/drivers/test_impl_rabbit.py @@ -176,7 +176,8 @@ class TestRabbitPublisher(test_utils.BaseTestCase): def test_send_with_timeout(self, fake_publish): transport = oslo_messaging.get_transport(self.conf, 'kombu+memory:////') - with transport._driver._get_connection(driver_common.PURPOSE_SEND) as pool_conn: + with transport._driver._get_connection( + driver_common.PURPOSE_SEND) as pool_conn: conn = pool_conn.connection conn._publish(mock.Mock(), 'msg', routing_key='routing_key', timeout=1) @@ -186,7 +187,8 @@ class TestRabbitPublisher(test_utils.BaseTestCase): def test_send_no_timeout(self, fake_publish): transport = oslo_messaging.get_transport(self.conf, 'kombu+memory:////') - with transport._driver._get_connection(driver_common.PURPOSE_SEND) as pool_conn: + with transport._driver._get_connection( + driver_common.PURPOSE_SEND) as pool_conn: conn = pool_conn.connection conn._publish(mock.Mock(), 'msg', routing_key='routing_key') fake_publish.assert_called_with('msg', expiration=None) @@ -206,7 +208,8 @@ class TestRabbitPublisher(test_utils.BaseTestCase): type='topic', passive=False) - with transport._driver._get_connection(driver_common.PURPOSE_SEND) as pool_conn: + with transport._driver._get_connection( + driver_common.PURPOSE_SEND) as pool_conn: conn = pool_conn.connection exc = conn.connection.channel_errors[0] @@ -239,7 +242,8 @@ class TestRabbitConsume(test_utils.BaseTestCase): 'kombu+memory:////') self.addCleanup(transport.cleanup) deadline = time.time() + 6 - with transport._driver._get_connection(driver_common.PURPOSE_LISTEN) as conn: + with transport._driver._get_connection( + driver_common.PURPOSE_LISTEN) as conn: self.assertRaises(driver_common.Timeout, conn.consume, timeout=3) @@ -258,7 +262,8 @@ class TestRabbitConsume(test_utils.BaseTestCase): transport = oslo_messaging.get_transport(self.conf, 'kombu+memory:////') self.addCleanup(transport.cleanup) - with transport._driver._get_connection(driver_common.PURPOSE_LISTEN) as conn: + with transport._driver._get_connection( + driver_common.PURPOSE_LISTEN) as conn: channel = conn.connection.channel with mock.patch('kombu.connection.Connection.connected', new_callable=mock.PropertyMock, @@ -468,7 +473,8 @@ class TestSendReceive(test_utils.BaseTestCase): # kombu_missing_consumer_retry_timeout seconds to fail # next immediately fail dt = time.time() - start - timeout = self.conf.oslo_messaging_rabbit.kombu_missing_consumer_retry_timeout + rabbit_conf = self.conf.oslo_messaging_rabbit + timeout = rabbit_conf.kombu_missing_consumer_retry_timeout self.assertTrue(timeout <= dt < (timeout + 0.100), dt) self.assertEqual(len(senders), len(replies)) diff --git a/oslo_messaging/tests/drivers/zmq/matchmaker/__init__.py b/oslo_messaging/tests/drivers/zmq/matchmaker/__init__.py index 8b1378917..e69de29bb 100644 --- a/oslo_messaging/tests/drivers/zmq/matchmaker/__init__.py +++ b/oslo_messaging/tests/drivers/zmq/matchmaker/__init__.py @@ -1 +0,0 @@ - diff --git a/oslo_messaging/tests/drivers/zmq/test_pub_sub.py b/oslo_messaging/tests/drivers/zmq/test_pub_sub.py index 8e17fb85e..924ccfba4 100644 --- a/oslo_messaging/tests/drivers/zmq/test_pub_sub.py +++ b/oslo_messaging/tests/drivers/zmq/test_pub_sub.py @@ -117,4 +117,3 @@ class TestPubSub(zmq_common.ZmqBaseTestCase): self._check_listener(self.listeners[0]) self._check_listener(self.listeners[1]) - diff --git a/oslo_messaging/tests/executors/test_executor.py b/oslo_messaging/tests/executors/test_executor.py index fb91c11be..e5cce5395 100644 --- a/oslo_messaging/tests/executors/test_executor.py +++ b/oslo_messaging/tests/executors/test_executor.py @@ -181,7 +181,8 @@ class TestExecutor(test_utils.BaseTestCase): self.assertTrue(executor.wait()) def test_dead_wait(self): - dispatcher, _endpoint, _event, _run_executor = self._create_dispatcher() + (dispatcher, _endpoint, _event, + _run_executor) = self._create_dispatcher() listener = mock.Mock(spec=['poll', 'stop']) executor = self.executor(self.conf, listener, dispatcher) executor.stop() diff --git a/oslo_messaging/tests/functional/test_functional.py b/oslo_messaging/tests/functional/test_functional.py index d9ef04682..ac169126b 100644 --- a/oslo_messaging/tests/functional/test_functional.py +++ b/oslo_messaging/tests/functional/test_functional.py @@ -256,7 +256,7 @@ class NotifyTestCase(utils.SkipIfNoTransportURL): self.skipTest("QPID-6307") if self.url.startswith("zmq:"): self.skipTest("ZeroMQ-PUB-SUB") - + listener_a = self.useFixture( utils.NotificationFixture(self.conf, self.url, ['test-topic'])) diff --git a/oslo_messaging/tests/functional/zmq/multiproc_utils.py b/oslo_messaging/tests/functional/zmq/multiproc_utils.py index fb66615b6..be6335f30 100644 --- a/oslo_messaging/tests/functional/zmq/multiproc_utils.py +++ b/oslo_messaging/tests/functional/zmq/multiproc_utils.py @@ -57,7 +57,8 @@ class QueueHandler(logging.Handler): try: ei = record.exc_info if ei: - dummy = self.format(record) # just to get traceback text into record.exc_text + # just to get traceback text into record.exc_text + dummy = self.format(record) record.exc_info = None # not needed any more self.queue.put_nowait(record) except (KeyboardInterrupt, SystemExit): @@ -148,8 +149,7 @@ class Server(object): LOG.debug("Starting RPC server") transport = oslo_messaging.get_transport(conf, url=url) - target = oslo_messaging.Target(topic=self.topic, - server=self.name) + target = oslo_messaging.Target(topic=self.topic, server=self.name) self.rpc_server = oslo_messaging.get_rpc_server( transport=transport, target=target, endpoints=[ReplyServerEndpoint()], @@ -221,7 +221,8 @@ class MutliprocTestCase(utils.SkipIfNoTransportURL): srv.start() if wait_for_server: while not srv.ready.value: - LOG.debug("[SPAWN] %s (waiting for server ready)..." % srv.name) + LOG.debug("[SPAWN] %s (waiting for server ready)...", + srv.name) time.sleep(1) LOG.debug("[SPAWN] Server %s:%d started.", srv.name, srv.process.pid) self.spawned.append(srv) diff --git a/oslo_messaging/tests/notify/test_listener.py b/oslo_messaging/tests/notify/test_listener.py index 3e534aaac..040283497 100644 --- a/oslo_messaging/tests/notify/test_listener.py +++ b/oslo_messaging/tests/notify/test_listener.py @@ -252,7 +252,6 @@ class TestNotifyListener(test_utils.BaseTestCase, ListenerSetupMixin): endpoint.info.assert_has_calls([mock.call(messages * 5)]) - def test_one_topic(self): transport = msg_notifier.get_notification_transport( self.conf, url='fake:') diff --git a/oslo_messaging/tests/notify/test_notifier.py b/oslo_messaging/tests/notify/test_notifier.py index 0b2da7fbb..1a4ab5cd0 100644 --- a/oslo_messaging/tests/notify/test_notifier.py +++ b/oslo_messaging/tests/notify/test_notifier.py @@ -329,7 +329,6 @@ class TestLogNotifier(test_utils.BaseTestCase): json_str = jsonutils.dumps(message) mask_str = strutils.mask_password(json_str) - with mock.patch.object(logging, 'getLogger') as gl: gl.return_value = logger driver.notify(None, message, 'info', 0) diff --git a/oslo_messaging/tests/rpc/test_server.py b/oslo_messaging/tests/rpc/test_server.py index 2bf08fd3f..70ce9f9df 100644 --- a/oslo_messaging/tests/rpc/test_server.py +++ b/oslo_messaging/tests/rpc/test_server.py @@ -99,7 +99,6 @@ class ServerSetupMixin(object): client.cast({}, 'stop') server.wait() - def _setup_client(self, transport, topic='testtopic'): return oslo_messaging.RPCClient(transport, oslo_messaging.Target(topic=topic), @@ -532,6 +531,7 @@ class TestMultipleServers(test_utils.BaseTestCase, ServerSetupMixin): TestMultipleServers.generate_scenarios() + class TestServerLocking(test_utils.BaseTestCase): def setUp(self): super(TestServerLocking, self).setUp(conf=cfg.ConfigOpts()) @@ -543,6 +543,7 @@ class TestServerLocking(test_utils.BaseTestCase): return method executors = [] + class FakeExecutor(object): def __init__(self, *args, **kwargs): self._lock = threading.Lock() @@ -554,6 +555,7 @@ class TestServerLocking(test_utils.BaseTestCase): stop = _logmethod('stop') wait = _logmethod('wait') execute = _logmethod('execute') + self.executors = executors self.server = oslo_messaging.MessageHandlingServer(mock.Mock(), @@ -605,6 +607,7 @@ class TestServerLocking(test_utils.BaseTestCase): done_event = threading.Event() runner = [None] + class SteppingFakeExecutor(self.server._executor_cls): def start(self): # Tell the test which thread won the race @@ -616,6 +619,7 @@ class TestServerLocking(test_utils.BaseTestCase): done_event.set() finish_event.wait() + self.server._executor_cls = SteppingFakeExecutor start1 = eventlet.spawn(self.server.start) @@ -684,12 +688,14 @@ class TestServerLocking(test_utils.BaseTestCase): start_state = self.server._states['start'] old_wait_for_completion = start_state.wait_for_completion waited = [False] + def new_wait_for_completion(*args, **kwargs): if not waited[0]: waited[0] = True complete_waiting_callback.set() complete_event.wait() old_wait_for_completion(*args, **kwargs) + start_state.wait_for_completion = new_wait_for_completion # thread1 will wait for start to complete until we signal it diff --git a/oslo_messaging/tests/test_fixture.py b/oslo_messaging/tests/test_fixture.py index 5c7218f0b..a8c2eb69c 100644 --- a/oslo_messaging/tests/test_fixture.py +++ b/oslo_messaging/tests/test_fixture.py @@ -78,4 +78,4 @@ class TestConfFixture(test_utils.BaseTestCase): conf.oslo_messaging_notifications.driver) self.assertIsNone(conf.oslo_messaging_notifications.transport_url) self.assertEqual(['notifications'], - conf.oslo_messaging_notifications.topics) \ No newline at end of file + conf.oslo_messaging_notifications.topics) diff --git a/oslo_messaging/tests/test_utils.py b/oslo_messaging/tests/test_utils.py index 5e8354a4d..908c25fbf 100644 --- a/oslo_messaging/tests/test_utils.py +++ b/oslo_messaging/tests/test_utils.py @@ -97,4 +97,3 @@ class TimerTestCase(test_utils.BaseTestCase): remaining = t.check_return(callback, 1, a='b') self.assertEqual(0, remaining) callback.assert_called_once_with(1, a='b') -