Fixed a couple of pep8 errors/warnings
Fixed pep8 errors: * E127 continuation line over-indented for visual indent * E226 missing whitespace around arithmetic operator * E231 missing whitespace after ',' * E241 multiple spaces after ',' * E261 at least two spaces before inline comment * E301 expected 1 blank line, found 0 * E302 expected 2 blank lines, found 1 * E303 too many blank lines (2) * E501 line too long (80 > 79 characters) Fixed pep8 warnings: * W292 no newline at end of file * W391 blank line at end of file Change-Id: I1736f8a42c3a335a17a0b9b6e64782487ed3a495
This commit is contained in:
parent
fb1164f1fc
commit
166cfbfb1b
@ -1 +0,0 @@
|
|||||||
|
|
@ -1 +0,0 @@
|
|||||||
|
|
@ -62,7 +62,7 @@ class PikaIncomingMessageTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
message.acknowledge()
|
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.assertEqual({"delivery_tag": self._delivery_tag},
|
||||||
self._channel.basic_ack.call_args[1])
|
self._channel.basic_ack.call_args[1])
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ class PikaIncomingMessageTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
message.acknowledge()
|
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):
|
def test_message_requeue(self):
|
||||||
message = pika_drv_msg.PikaIncomingMessage(
|
message = pika_drv_msg.PikaIncomingMessage(
|
||||||
@ -574,7 +574,7 @@ class RpcReplyPikaOutgoingMessageTestCase(unittest.TestCase):
|
|||||||
self.assertIsNone(props.reply_to)
|
self.assertIsNone(props.reply_to)
|
||||||
self.assertTrue(props.message_id)
|
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",
|
@patch("oslo_serialization.jsonutils.dumps",
|
||||||
new=functools.partial(jsonutils.dumps, sort_keys=True))
|
new=functools.partial(jsonutils.dumps, sort_keys=True))
|
||||||
def test_failure_message_send(self):
|
def test_failure_message_send(self):
|
||||||
@ -582,7 +582,6 @@ class RpcReplyPikaOutgoingMessageTestCase(unittest.TestCase):
|
|||||||
oslo_messaging.MessagingException("Error message"),
|
oslo_messaging.MessagingException("Error message"),
|
||||||
['It is a trace'])
|
['It is a trace'])
|
||||||
|
|
||||||
|
|
||||||
message = pika_drv_msg.RpcReplyPikaOutgoingMessage(
|
message = pika_drv_msg.RpcReplyPikaOutgoingMessage(
|
||||||
self._pika_engine, self._msg_id, failure_info=failure_info
|
self._pika_engine, self._msg_id, failure_info=failure_info
|
||||||
)
|
)
|
||||||
|
@ -107,17 +107,17 @@ class PikaPollerTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
res2 = poller.poll(prefetch_size=n)
|
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(incoming_message_class_mock.call_count, n)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self._poller_connection_mock.process_data_events.call_count, 1)
|
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(res2[i], incoming_message_class_mock.return_value)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
incoming_message_class_mock.call_args_list[i+1][0],
|
incoming_message_class_mock.call_args_list[i + 1][0],
|
||||||
(self._pika_engine, None) + params[i+1][1:]
|
(self._pika_engine, None) + params[i + 1][1:]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertTrue(self._pika_engine.create_connection.called)
|
self.assertTrue(self._pika_engine.create_connection.called)
|
||||||
|
@ -176,7 +176,8 @@ class TestRabbitPublisher(test_utils.BaseTestCase):
|
|||||||
def test_send_with_timeout(self, fake_publish):
|
def test_send_with_timeout(self, fake_publish):
|
||||||
transport = oslo_messaging.get_transport(self.conf,
|
transport = oslo_messaging.get_transport(self.conf,
|
||||||
'kombu+memory:////')
|
'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 = pool_conn.connection
|
||||||
conn._publish(mock.Mock(), 'msg', routing_key='routing_key',
|
conn._publish(mock.Mock(), 'msg', routing_key='routing_key',
|
||||||
timeout=1)
|
timeout=1)
|
||||||
@ -186,7 +187,8 @@ class TestRabbitPublisher(test_utils.BaseTestCase):
|
|||||||
def test_send_no_timeout(self, fake_publish):
|
def test_send_no_timeout(self, fake_publish):
|
||||||
transport = oslo_messaging.get_transport(self.conf,
|
transport = oslo_messaging.get_transport(self.conf,
|
||||||
'kombu+memory:////')
|
'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 = pool_conn.connection
|
||||||
conn._publish(mock.Mock(), 'msg', routing_key='routing_key')
|
conn._publish(mock.Mock(), 'msg', routing_key='routing_key')
|
||||||
fake_publish.assert_called_with('msg', expiration=None)
|
fake_publish.assert_called_with('msg', expiration=None)
|
||||||
@ -206,7 +208,8 @@ class TestRabbitPublisher(test_utils.BaseTestCase):
|
|||||||
type='topic',
|
type='topic',
|
||||||
passive=False)
|
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
|
conn = pool_conn.connection
|
||||||
exc = conn.connection.channel_errors[0]
|
exc = conn.connection.channel_errors[0]
|
||||||
|
|
||||||
@ -239,7 +242,8 @@ class TestRabbitConsume(test_utils.BaseTestCase):
|
|||||||
'kombu+memory:////')
|
'kombu+memory:////')
|
||||||
self.addCleanup(transport.cleanup)
|
self.addCleanup(transport.cleanup)
|
||||||
deadline = time.time() + 6
|
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,
|
self.assertRaises(driver_common.Timeout,
|
||||||
conn.consume, timeout=3)
|
conn.consume, timeout=3)
|
||||||
|
|
||||||
@ -258,7 +262,8 @@ class TestRabbitConsume(test_utils.BaseTestCase):
|
|||||||
transport = oslo_messaging.get_transport(self.conf,
|
transport = oslo_messaging.get_transport(self.conf,
|
||||||
'kombu+memory:////')
|
'kombu+memory:////')
|
||||||
self.addCleanup(transport.cleanup)
|
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
|
channel = conn.connection.channel
|
||||||
with mock.patch('kombu.connection.Connection.connected',
|
with mock.patch('kombu.connection.Connection.connected',
|
||||||
new_callable=mock.PropertyMock,
|
new_callable=mock.PropertyMock,
|
||||||
@ -468,7 +473,8 @@ class TestSendReceive(test_utils.BaseTestCase):
|
|||||||
# kombu_missing_consumer_retry_timeout seconds to fail
|
# kombu_missing_consumer_retry_timeout seconds to fail
|
||||||
# next immediately fail
|
# next immediately fail
|
||||||
dt = time.time() - start
|
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.assertTrue(timeout <= dt < (timeout + 0.100), dt)
|
||||||
|
|
||||||
self.assertEqual(len(senders), len(replies))
|
self.assertEqual(len(senders), len(replies))
|
||||||
|
@ -1 +0,0 @@
|
|||||||
|
|
@ -117,4 +117,3 @@ class TestPubSub(zmq_common.ZmqBaseTestCase):
|
|||||||
|
|
||||||
self._check_listener(self.listeners[0])
|
self._check_listener(self.listeners[0])
|
||||||
self._check_listener(self.listeners[1])
|
self._check_listener(self.listeners[1])
|
||||||
|
|
||||||
|
@ -181,7 +181,8 @@ class TestExecutor(test_utils.BaseTestCase):
|
|||||||
self.assertTrue(executor.wait())
|
self.assertTrue(executor.wait())
|
||||||
|
|
||||||
def test_dead_wait(self):
|
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'])
|
listener = mock.Mock(spec=['poll', 'stop'])
|
||||||
executor = self.executor(self.conf, listener, dispatcher)
|
executor = self.executor(self.conf, listener, dispatcher)
|
||||||
executor.stop()
|
executor.stop()
|
||||||
|
@ -256,7 +256,7 @@ class NotifyTestCase(utils.SkipIfNoTransportURL):
|
|||||||
self.skipTest("QPID-6307")
|
self.skipTest("QPID-6307")
|
||||||
if self.url.startswith("zmq:"):
|
if self.url.startswith("zmq:"):
|
||||||
self.skipTest("ZeroMQ-PUB-SUB")
|
self.skipTest("ZeroMQ-PUB-SUB")
|
||||||
|
|
||||||
listener_a = self.useFixture(
|
listener_a = self.useFixture(
|
||||||
utils.NotificationFixture(self.conf, self.url, ['test-topic']))
|
utils.NotificationFixture(self.conf, self.url, ['test-topic']))
|
||||||
|
|
||||||
|
@ -57,7 +57,8 @@ class QueueHandler(logging.Handler):
|
|||||||
try:
|
try:
|
||||||
ei = record.exc_info
|
ei = record.exc_info
|
||||||
if ei:
|
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
|
record.exc_info = None # not needed any more
|
||||||
self.queue.put_nowait(record)
|
self.queue.put_nowait(record)
|
||||||
except (KeyboardInterrupt, SystemExit):
|
except (KeyboardInterrupt, SystemExit):
|
||||||
@ -148,8 +149,7 @@ class Server(object):
|
|||||||
LOG.debug("Starting RPC server")
|
LOG.debug("Starting RPC server")
|
||||||
|
|
||||||
transport = oslo_messaging.get_transport(conf, url=url)
|
transport = oslo_messaging.get_transport(conf, url=url)
|
||||||
target = oslo_messaging.Target(topic=self.topic,
|
target = oslo_messaging.Target(topic=self.topic, server=self.name)
|
||||||
server=self.name)
|
|
||||||
self.rpc_server = oslo_messaging.get_rpc_server(
|
self.rpc_server = oslo_messaging.get_rpc_server(
|
||||||
transport=transport, target=target,
|
transport=transport, target=target,
|
||||||
endpoints=[ReplyServerEndpoint()],
|
endpoints=[ReplyServerEndpoint()],
|
||||||
@ -221,7 +221,8 @@ class MutliprocTestCase(utils.SkipIfNoTransportURL):
|
|||||||
srv.start()
|
srv.start()
|
||||||
if wait_for_server:
|
if wait_for_server:
|
||||||
while not srv.ready.value:
|
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)
|
time.sleep(1)
|
||||||
LOG.debug("[SPAWN] Server %s:%d started.", srv.name, srv.process.pid)
|
LOG.debug("[SPAWN] Server %s:%d started.", srv.name, srv.process.pid)
|
||||||
self.spawned.append(srv)
|
self.spawned.append(srv)
|
||||||
|
@ -252,7 +252,6 @@ class TestNotifyListener(test_utils.BaseTestCase, ListenerSetupMixin):
|
|||||||
|
|
||||||
endpoint.info.assert_has_calls([mock.call(messages * 5)])
|
endpoint.info.assert_has_calls([mock.call(messages * 5)])
|
||||||
|
|
||||||
|
|
||||||
def test_one_topic(self):
|
def test_one_topic(self):
|
||||||
transport = msg_notifier.get_notification_transport(
|
transport = msg_notifier.get_notification_transport(
|
||||||
self.conf, url='fake:')
|
self.conf, url='fake:')
|
||||||
|
@ -329,7 +329,6 @@ class TestLogNotifier(test_utils.BaseTestCase):
|
|||||||
json_str = jsonutils.dumps(message)
|
json_str = jsonutils.dumps(message)
|
||||||
mask_str = strutils.mask_password(json_str)
|
mask_str = strutils.mask_password(json_str)
|
||||||
|
|
||||||
|
|
||||||
with mock.patch.object(logging, 'getLogger') as gl:
|
with mock.patch.object(logging, 'getLogger') as gl:
|
||||||
gl.return_value = logger
|
gl.return_value = logger
|
||||||
driver.notify(None, message, 'info', 0)
|
driver.notify(None, message, 'info', 0)
|
||||||
|
@ -99,7 +99,6 @@ class ServerSetupMixin(object):
|
|||||||
client.cast({}, 'stop')
|
client.cast({}, 'stop')
|
||||||
server.wait()
|
server.wait()
|
||||||
|
|
||||||
|
|
||||||
def _setup_client(self, transport, topic='testtopic'):
|
def _setup_client(self, transport, topic='testtopic'):
|
||||||
return oslo_messaging.RPCClient(transport,
|
return oslo_messaging.RPCClient(transport,
|
||||||
oslo_messaging.Target(topic=topic),
|
oslo_messaging.Target(topic=topic),
|
||||||
@ -532,6 +531,7 @@ class TestMultipleServers(test_utils.BaseTestCase, ServerSetupMixin):
|
|||||||
|
|
||||||
TestMultipleServers.generate_scenarios()
|
TestMultipleServers.generate_scenarios()
|
||||||
|
|
||||||
|
|
||||||
class TestServerLocking(test_utils.BaseTestCase):
|
class TestServerLocking(test_utils.BaseTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestServerLocking, self).setUp(conf=cfg.ConfigOpts())
|
super(TestServerLocking, self).setUp(conf=cfg.ConfigOpts())
|
||||||
@ -543,6 +543,7 @@ class TestServerLocking(test_utils.BaseTestCase):
|
|||||||
return method
|
return method
|
||||||
|
|
||||||
executors = []
|
executors = []
|
||||||
|
|
||||||
class FakeExecutor(object):
|
class FakeExecutor(object):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self._lock = threading.Lock()
|
self._lock = threading.Lock()
|
||||||
@ -554,6 +555,7 @@ class TestServerLocking(test_utils.BaseTestCase):
|
|||||||
stop = _logmethod('stop')
|
stop = _logmethod('stop')
|
||||||
wait = _logmethod('wait')
|
wait = _logmethod('wait')
|
||||||
execute = _logmethod('execute')
|
execute = _logmethod('execute')
|
||||||
|
|
||||||
self.executors = executors
|
self.executors = executors
|
||||||
|
|
||||||
self.server = oslo_messaging.MessageHandlingServer(mock.Mock(),
|
self.server = oslo_messaging.MessageHandlingServer(mock.Mock(),
|
||||||
@ -605,6 +607,7 @@ class TestServerLocking(test_utils.BaseTestCase):
|
|||||||
done_event = threading.Event()
|
done_event = threading.Event()
|
||||||
|
|
||||||
runner = [None]
|
runner = [None]
|
||||||
|
|
||||||
class SteppingFakeExecutor(self.server._executor_cls):
|
class SteppingFakeExecutor(self.server._executor_cls):
|
||||||
def start(self):
|
def start(self):
|
||||||
# Tell the test which thread won the race
|
# Tell the test which thread won the race
|
||||||
@ -616,6 +619,7 @@ class TestServerLocking(test_utils.BaseTestCase):
|
|||||||
done_event.set()
|
done_event.set()
|
||||||
|
|
||||||
finish_event.wait()
|
finish_event.wait()
|
||||||
|
|
||||||
self.server._executor_cls = SteppingFakeExecutor
|
self.server._executor_cls = SteppingFakeExecutor
|
||||||
|
|
||||||
start1 = eventlet.spawn(self.server.start)
|
start1 = eventlet.spawn(self.server.start)
|
||||||
@ -684,12 +688,14 @@ class TestServerLocking(test_utils.BaseTestCase):
|
|||||||
start_state = self.server._states['start']
|
start_state = self.server._states['start']
|
||||||
old_wait_for_completion = start_state.wait_for_completion
|
old_wait_for_completion = start_state.wait_for_completion
|
||||||
waited = [False]
|
waited = [False]
|
||||||
|
|
||||||
def new_wait_for_completion(*args, **kwargs):
|
def new_wait_for_completion(*args, **kwargs):
|
||||||
if not waited[0]:
|
if not waited[0]:
|
||||||
waited[0] = True
|
waited[0] = True
|
||||||
complete_waiting_callback.set()
|
complete_waiting_callback.set()
|
||||||
complete_event.wait()
|
complete_event.wait()
|
||||||
old_wait_for_completion(*args, **kwargs)
|
old_wait_for_completion(*args, **kwargs)
|
||||||
|
|
||||||
start_state.wait_for_completion = new_wait_for_completion
|
start_state.wait_for_completion = new_wait_for_completion
|
||||||
|
|
||||||
# thread1 will wait for start to complete until we signal it
|
# thread1 will wait for start to complete until we signal it
|
||||||
|
@ -78,4 +78,4 @@ class TestConfFixture(test_utils.BaseTestCase):
|
|||||||
conf.oslo_messaging_notifications.driver)
|
conf.oslo_messaging_notifications.driver)
|
||||||
self.assertIsNone(conf.oslo_messaging_notifications.transport_url)
|
self.assertIsNone(conf.oslo_messaging_notifications.transport_url)
|
||||||
self.assertEqual(['notifications'],
|
self.assertEqual(['notifications'],
|
||||||
conf.oslo_messaging_notifications.topics)
|
conf.oslo_messaging_notifications.topics)
|
||||||
|
@ -97,4 +97,3 @@ class TimerTestCase(test_utils.BaseTestCase):
|
|||||||
remaining = t.check_return(callback, 1, a='b')
|
remaining = t.check_return(callback, 1, a='b')
|
||||||
self.assertEqual(0, remaining)
|
self.assertEqual(0, remaining)
|
||||||
callback.assert_called_once_with(1, a='b')
|
callback.assert_called_once_with(1, a='b')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user