diff --git a/oslo_messaging/tests/drivers/zmq/test_impl_zmq.py b/oslo_messaging/tests/drivers/zmq/test_impl_zmq.py index 4ba1f0dd0..6280342d5 100644 --- a/oslo_messaging/tests/drivers/zmq/test_impl_zmq.py +++ b/oslo_messaging/tests/drivers/zmq/test_impl_zmq.py @@ -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: diff --git a/oslo_messaging/tests/drivers/zmq/test_pub_sub.py b/oslo_messaging/tests/drivers/zmq/test_pub_sub.py index 0ca16278e..345d8fdc1 100644 --- a/oslo_messaging/tests/drivers/zmq/test_pub_sub.py +++ b/oslo_messaging/tests/drivers/zmq/test_pub_sub.py @@ -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 diff --git a/oslo_messaging/tests/drivers/zmq/zmq_common.py b/oslo_messaging/tests/drivers/zmq/zmq_common.py index 21b56e6a9..85998da18 100644 --- a/oslo_messaging/tests/drivers/zmq/zmq_common.py +++ b/oslo_messaging/tests/drivers/zmq/zmq_common.py @@ -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() diff --git a/oslo_messaging/tests/functional/zmq/multiproc_utils.py b/oslo_messaging/tests/functional/zmq/multiproc_utils.py index e07f1a239..a1a78085d 100644 --- a/oslo_messaging/tests/functional/zmq/multiproc_utils.py +++ b/oslo_messaging/tests/functional/zmq/multiproc_utils.py @@ -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) diff --git a/oslo_messaging/tests/rpc/test_server.py b/oslo_messaging/tests/rpc/test_server.py index 9f7faef8d..b26938e1a 100644 --- a/oslo_messaging/tests/rpc/test_server.py +++ b/oslo_messaging/tests/rpc/test_server.py @@ -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() diff --git a/tox.ini b/tox.ini index 19d5e0160..a86ff82db 100644 --- a/tox.ini +++ b/tox.ini @@ -45,7 +45,7 @@ commands = bandit -c bandit.yaml -r oslo_messaging -n5 -p oslo.messaging [flake8] show-source = True ignore = H405 -exclude = .tox,dist,doc,*.egg,build,__init__.py,tests +exclude = .tox,dist,doc,*.egg,build,__init__.py [hacking] import_exceptions =