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:
Javeme 2016-01-22 19:42:07 +08:00
parent fb1164f1fc
commit 166cfbfb1b
15 changed files with 35 additions and 29 deletions

View File

@ -1 +0,0 @@

View File

@ -1 +0,0 @@

View File

@ -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
)

View File

@ -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)

View File

@ -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))

View File

@ -117,4 +117,3 @@ class TestPubSub(zmq_common.ZmqBaseTestCase):
self._check_listener(self.listeners[0])
self._check_listener(self.listeners[1])

View File

@ -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()

View File

@ -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']))

View File

@ -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)

View File

@ -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:')

View File

@ -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)

View File

@ -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

View File

@ -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)
conf.oslo_messaging_notifications.topics)

View File

@ -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')