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:
Davanum Srinivas 2016-02-02 11:34:01 -05:00
parent 11d7c44a36
commit 44c60cf7e7
6 changed files with 20 additions and 22 deletions

View File

@ -19,8 +19,8 @@ import oslo_messaging
from oslo_messaging._drivers import impl_zmq from oslo_messaging._drivers import impl_zmq
from oslo_messaging._drivers.zmq_driver import zmq_async from oslo_messaging._drivers.zmq_driver import zmq_async
from oslo_messaging._drivers.zmq_driver import zmq_socket 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.drivers.zmq import zmq_common
from oslo_messaging.tests import utils as test_utils
zmq = zmq_async.import_zmq() zmq = zmq_async.import_zmq()
@ -42,7 +42,7 @@ class ZmqTestPortsRange(zmq_common.ZmqBaseTestCase):
for i in range(10): for i in range(10):
try: try:
target = oslo_messaging.Target(topic='testtopic_'+str(i)) target = oslo_messaging.Target(topic='testtopic_' + str(i))
new_listener = self.driver.listen(target) new_listener = self.driver.listen(target)
listeners.append(new_listener) listeners.append(new_listener)
except zmq_socket.ZmqPortRangeExceededException: except zmq_socket.ZmqPortRangeExceededException:

View File

@ -18,10 +18,10 @@ import time
import contextlib import contextlib
import oslo_messaging import oslo_messaging
from oslo_messaging._drivers.zmq_driver import zmq_async
from oslo_messaging._drivers.zmq_driver.client.publishers \ from oslo_messaging._drivers.zmq_driver.client.publishers \
import zmq_pub_publisher import zmq_pub_publisher
from oslo_messaging._drivers.zmq_driver.client import zmq_request 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 from oslo_messaging.tests.drivers.zmq import zmq_common

View File

@ -20,7 +20,7 @@ import testtools
import oslo_messaging import oslo_messaging
from oslo_messaging._drivers.zmq_driver import zmq_async 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 from oslo_messaging.tests import utils as test_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -57,7 +57,7 @@ class TestServerListener(object):
self.message = message self.message = message
message.reply(reply=True) message.reply(reply=True)
except Exception: except Exception:
LOG.exception(_("Unexpected exception occurred.")) LOG.exception(_LE("Unexpected exception occurred."))
def stop(self): def stop(self):
self.executor.stop() self.executor.stop()

View File

@ -17,8 +17,8 @@ import logging.handlers
import multiprocessing import multiprocessing
import os import os
import sys import sys
import time
import threading import threading
import time
import uuid import uuid
from oslo_config import cfg from oslo_config import cfg
@ -34,23 +34,19 @@ LOG = logging.getLogger(__name__)
class QueueHandler(logging.Handler): 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 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. user code for use with earlier Python versions.
""" """
def __init__(self, queue): def __init__(self, queue):
""" """Initialise an instance, using the passed queue."""
Initialise an instance, using the passed queue.
"""
logging.Handler.__init__(self) logging.Handler.__init__(self)
self.queue = queue self.queue = queue
def emit(self, record): def emit(self, record):
""" """Emit a record.
Emit a record.
Writes the LogRecord to the queue. Writes the LogRecord to the queue.
""" """
@ -63,7 +59,7 @@ class QueueHandler(logging.Handler):
self.queue.put_nowait(record) self.queue.put_nowait(record)
except (KeyboardInterrupt, SystemExit): except (KeyboardInterrupt, SystemExit):
raise raise
except: except Exception:
self.handleError(record) self.handleError(record)

View File

@ -14,7 +14,6 @@
# under the License. # under the License.
import eventlet import eventlet
import time
import threading import threading
from oslo_config import cfg from oslo_config import cfg
@ -137,8 +136,11 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin):
serializer = object() serializer = object()
class MagicMockIgnoreArgs(mock.MagicMock): class MagicMockIgnoreArgs(mock.MagicMock):
'''A MagicMock which can never misinterpret the arguments passed to '''MagicMock ignores arguments.
it during construction.'''
A MagicMock which can never misinterpret the arguments passed to
it during construction.
'''
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(MagicMockIgnoreArgs, self).__init__() super(MagicMockIgnoreArgs, self).__init__()
@ -565,7 +567,7 @@ class TestServerLocking(test_utils.BaseTestCase):
def test_start_stop_wait(self): def test_start_stop_wait(self):
# Test a simple execution of start, stop, wait in order # 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.stop()
self.server.wait() self.server.wait()
@ -579,15 +581,15 @@ class TestServerLocking(test_utils.BaseTestCase):
# Test that if we call wait, stop, start, these will be correctly # Test that if we call wait, stop, start, these will be correctly
# reordered # 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 # This is non-deterministic, but there's not a great deal we can do
# about that # about that
eventlet.sleep(0) eventlet.sleep(0)
stop = eventlet.spawn(self.server.stop) eventlet.spawn(self.server.stop)
eventlet.sleep(0) eventlet.sleep(0)
start = eventlet.spawn(self.server.start) eventlet.spawn(self.server.start)
self.server.wait() self.server.wait()

View File

@ -45,7 +45,7 @@ commands = bandit -c bandit.yaml -r oslo_messaging -n5 -p oslo.messaging
[flake8] [flake8]
show-source = True show-source = True
ignore = H405 ignore = H405
exclude = .tox,dist,doc,*.egg,build,__init__.py,tests exclude = .tox,dist,doc,*.egg,build,__init__.py
[hacking] [hacking]
import_exceptions = import_exceptions =