Enable pep8 on oslo_messaging/tests
Somehow we sneaked in a change to ignore pep8 on tests/ directory. Let's cleanup the code and re-enable pep8 Closes-Bug: #1540981 Change-Id: Ic002134a0d0c498991b062466e00068d6ac1f1ab
This commit is contained in:
parent
11d7c44a36
commit
44c60cf7e7
@ -19,8 +19,8 @@ import oslo_messaging
|
||||
from oslo_messaging._drivers import impl_zmq
|
||||
from oslo_messaging._drivers.zmq_driver import zmq_async
|
||||
from oslo_messaging._drivers.zmq_driver import zmq_socket
|
||||
from oslo_messaging.tests import utils as test_utils
|
||||
from oslo_messaging.tests.drivers.zmq import zmq_common
|
||||
from oslo_messaging.tests import utils as test_utils
|
||||
|
||||
|
||||
zmq = zmq_async.import_zmq()
|
||||
@ -42,7 +42,7 @@ class ZmqTestPortsRange(zmq_common.ZmqBaseTestCase):
|
||||
|
||||
for i in range(10):
|
||||
try:
|
||||
target = oslo_messaging.Target(topic='testtopic_'+str(i))
|
||||
target = oslo_messaging.Target(topic='testtopic_' + str(i))
|
||||
new_listener = self.driver.listen(target)
|
||||
listeners.append(new_listener)
|
||||
except zmq_socket.ZmqPortRangeExceededException:
|
||||
|
@ -18,10 +18,10 @@ import time
|
||||
import contextlib
|
||||
|
||||
import oslo_messaging
|
||||
from oslo_messaging._drivers.zmq_driver import zmq_async
|
||||
from oslo_messaging._drivers.zmq_driver.client.publishers \
|
||||
import zmq_pub_publisher
|
||||
from oslo_messaging._drivers.zmq_driver.client import zmq_request
|
||||
from oslo_messaging._drivers.zmq_driver import zmq_async
|
||||
from oslo_messaging.tests.drivers.zmq import zmq_common
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ import testtools
|
||||
|
||||
import oslo_messaging
|
||||
from oslo_messaging._drivers.zmq_driver import zmq_async
|
||||
from oslo_messaging._i18n import _
|
||||
from oslo_messaging._i18n import _LE
|
||||
from oslo_messaging.tests import utils as test_utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -57,7 +57,7 @@ class TestServerListener(object):
|
||||
self.message = message
|
||||
message.reply(reply=True)
|
||||
except Exception:
|
||||
LOG.exception(_("Unexpected exception occurred."))
|
||||
LOG.exception(_LE("Unexpected exception occurred."))
|
||||
|
||||
def stop(self):
|
||||
self.executor.stop()
|
||||
|
@ -17,8 +17,8 @@ import logging.handlers
|
||||
import multiprocessing
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import threading
|
||||
import time
|
||||
import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
@ -34,23 +34,19 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class QueueHandler(logging.Handler):
|
||||
"""
|
||||
This is a logging handler which sends events to a multiprocessing queue.
|
||||
"""This is a logging handler which sends events to a multiprocessing queue.
|
||||
|
||||
The plan is to add it to Python 3.2, but this can be copy pasted into
|
||||
user code for use with earlier Python versions.
|
||||
"""
|
||||
|
||||
def __init__(self, queue):
|
||||
"""
|
||||
Initialise an instance, using the passed queue.
|
||||
"""
|
||||
"""Initialise an instance, using the passed queue."""
|
||||
logging.Handler.__init__(self)
|
||||
self.queue = queue
|
||||
|
||||
def emit(self, record):
|
||||
"""
|
||||
Emit a record.
|
||||
"""Emit a record.
|
||||
|
||||
Writes the LogRecord to the queue.
|
||||
"""
|
||||
@ -63,7 +59,7 @@ class QueueHandler(logging.Handler):
|
||||
self.queue.put_nowait(record)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
except Exception:
|
||||
self.handleError(record)
|
||||
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
import eventlet
|
||||
import time
|
||||
import threading
|
||||
|
||||
from oslo_config import cfg
|
||||
@ -137,8 +136,11 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin):
|
||||
serializer = object()
|
||||
|
||||
class MagicMockIgnoreArgs(mock.MagicMock):
|
||||
'''A MagicMock which can never misinterpret the arguments passed to
|
||||
it during construction.'''
|
||||
'''MagicMock ignores arguments.
|
||||
|
||||
A MagicMock which can never misinterpret the arguments passed to
|
||||
it during construction.
|
||||
'''
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MagicMockIgnoreArgs, self).__init__()
|
||||
@ -565,7 +567,7 @@ class TestServerLocking(test_utils.BaseTestCase):
|
||||
def test_start_stop_wait(self):
|
||||
# Test a simple execution of start, stop, wait in order
|
||||
|
||||
thread = eventlet.spawn(self.server.start)
|
||||
eventlet.spawn(self.server.start)
|
||||
self.server.stop()
|
||||
self.server.wait()
|
||||
|
||||
@ -579,15 +581,15 @@ class TestServerLocking(test_utils.BaseTestCase):
|
||||
# Test that if we call wait, stop, start, these will be correctly
|
||||
# reordered
|
||||
|
||||
wait = eventlet.spawn(self.server.wait)
|
||||
eventlet.spawn(self.server.wait)
|
||||
# This is non-deterministic, but there's not a great deal we can do
|
||||
# about that
|
||||
eventlet.sleep(0)
|
||||
|
||||
stop = eventlet.spawn(self.server.stop)
|
||||
eventlet.spawn(self.server.stop)
|
||||
eventlet.sleep(0)
|
||||
|
||||
start = eventlet.spawn(self.server.start)
|
||||
eventlet.spawn(self.server.start)
|
||||
|
||||
self.server.wait()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user