summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsk Solem <ask@celeryproject.org>2013-01-17 13:50:01 +0000
committerAsk Solem <ask@celeryproject.org>2013-01-17 13:50:01 +0000
commitdd0fe3a3a6a1bb50209e697d7bef91473661bee2 (patch)
tree051c6aca716911da80a482049aad4373c049c222
parent02cd13bc9eec102bf0752a9e4ab3fe7cae078cd8 (diff)
downloadkombu-dd0fe3a3a6a1bb50209e697d7bef91473661bee2.tar.gz
More pep8ify
-rw-r--r--docs/_ext/applyxrefs.py4
-rw-r--r--docs/_ext/literals_to_xrefs.py6
-rw-r--r--docs/conf.py4
-rw-r--r--examples/simple_task_queue/client.py9
-rwxr-xr-xextra/release/bump_version.py2
-rwxr-xr-xextra/release/flakeplus.py2
-rw-r--r--funtests/setup.py2
-rw-r--r--funtests/transport.py18
-rw-r--r--kombu/tests/__init__.py17
-rw-r--r--kombu/tests/compat.py8
-rw-r--r--kombu/tests/mocks.py13
-rw-r--r--kombu/tests/test_common.py3
-rw-r--r--kombu/tests/test_compat.py19
-rw-r--r--kombu/tests/test_connection.py73
-rw-r--r--kombu/tests/test_entities.py24
-rw-r--r--kombu/tests/test_log.py15
-rw-r--r--kombu/tests/test_messaging.py8
-rw-r--r--kombu/tests/test_pidbox.py18
-rw-r--r--kombu/tests/test_serialization.py240
-rw-r--r--kombu/tests/test_utils.py58
-rw-r--r--kombu/tests/transport/test_amqplib.py8
-rw-r--r--kombu/tests/transport/test_base.py5
-rw-r--r--kombu/tests/transport/test_pyamqp.py14
-rw-r--r--kombu/tests/transport/test_redis.py41
-rw-r--r--kombu/tests/transport/virtual/test_base.py14
-rw-r--r--kombu/tests/transport/virtual/test_exchange.py108
-rw-r--r--kombu/tests/transport/virtual/test_scheduling.py16
-rw-r--r--kombu/tests/utilities/test_amq_manager.py10
-rw-r--r--kombu/tests/utilities/test_functional.py12
-rw-r--r--kombu/tests/utils.py4
-rw-r--r--pavement.py5
-rw-r--r--setup.py5
32 files changed, 457 insertions, 328 deletions
diff --git a/docs/_ext/applyxrefs.py b/docs/_ext/applyxrefs.py
index 027490b8..93222a33 100644
--- a/docs/_ext/applyxrefs.py
+++ b/docs/_ext/applyxrefs.py
@@ -5,9 +5,7 @@ import os
testing = False
-DONT_TOUCH = (
- './index.txt',
- )
+DONT_TOUCH = ('./index.txt', )
def target_name(fn):
diff --git a/docs/_ext/literals_to_xrefs.py b/docs/_ext/literals_to_xrefs.py
index e9dc7ca0..f1497565 100644
--- a/docs/_ext/literals_to_xrefs.py
+++ b/docs/_ext/literals_to_xrefs.py
@@ -95,8 +95,10 @@ def fixliterals(fname):
replace_type in ("class", "func", "meth"):
default = default[:-2]
replace_value = raw_input(
- colorize("Text <target> [", fg="yellow") + default + \
- colorize("]: ", fg="yellow")).strip()
+ colorize("Text <target> [", fg="yellow") +
+ default +
+ colorize("]: ", fg="yellow"),
+ ).strip()
if not replace_value:
replace_value = default
new.append(":%s:`%s`" % (replace_type, replace_value))
diff --git a/docs/conf.py b/docs/conf.py
index 27534746..bf39ded2 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -62,8 +62,8 @@ html_use_modindex = True
html_use_index = True
latex_documents = [
- ('index', 'Kombu.tex', ur'Kombu Documentation',
- ur'Ask Solem', 'manual'),
+ ('index', 'Kombu.tex', u'Kombu Documentation',
+ u'Ask Solem', 'manual'),
]
html_theme = "celery"
diff --git a/examples/simple_task_queue/client.py b/examples/simple_task_queue/client.py
index fe0a512b..b4731061 100644
--- a/examples/simple_task_queue/client.py
+++ b/examples/simple_task_queue/client.py
@@ -16,10 +16,11 @@ def send_as_task(connection, fun, args=(), kwargs={}, priority='mid'):
with producers[connection].acquire(block=True) as producer:
maybe_declare(task_exchange, producer.channel)
- producer.publish(payload, serializer='pickle',
- compression='bzip2',
- exchange=task_exchange,
- routing_key=routing_key)
+ producer.publish(payload,
+ serializer='pickle',
+ compression='bzip2',
+ exchange=task_exchange,
+ routing_key=routing_key)
if __name__ == '__main__':
from kombu import Connection
diff --git a/extra/release/bump_version.py b/extra/release/bump_version.py
index ccf7355e..5798f6a0 100755
--- a/extra/release/bump_version.py
+++ b/extra/release/bump_version.py
@@ -149,7 +149,7 @@ def bump(*files, **kwargs):
v.write(next)
print(cmd("git", "commit", "-m", "Bumps version to %s" % (to_str(next), ),
- *[f.filename for f in files]))
+ *[f.filename for f in files]))
print(cmd("git", "tag", "v%s" % (to_str(next), )))
diff --git a/extra/release/flakeplus.py b/extra/release/flakeplus.py
index 6fe1f1fc..4e1efd47 100755
--- a/extra/release/flakeplus.py
+++ b/extra/release/flakeplus.py
@@ -37,7 +37,7 @@ class FlakePP(object):
re_with = compile(RE_WITH)
re_noqa = compile(RE_NOQA)
map = {"abs": True, "print": False,
- "with": False, "with-used": False}
+ "with": False, "with-used": False}
def __init__(self, verbose=False):
self.verbose = verbose
diff --git a/funtests/setup.py b/funtests/setup.py
index fdb7a98c..a7ad8b4e 100644
--- a/funtests/setup.py
+++ b/funtests/setup.py
@@ -8,7 +8,7 @@ except ImportError:
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup # noqa
- from setuptools.command.install import install # noqa
+ from setuptools.command.install import install # noqa
class no_install(install):
diff --git a/funtests/transport.py b/funtests/transport.py
index 5924a72a..f6ae1e17 100644
--- a/funtests/transport.py
+++ b/funtests/transport.py
@@ -40,7 +40,7 @@ def consumeN(conn, consumer, n=1, timeout=30):
except socket.timeout:
seconds += 1
msg = "Received %s/%s messages. %s seconds passed." % (
- len(messages), n, seconds)
+ len(messages), n, seconds)
if seconds >= timeout:
raise socket.timeout(msg)
if seconds > 1:
@@ -113,7 +113,7 @@ class TransportCase(unittest.TestCase):
self.after_connect(self.connection)
except self.connection.connection_errors:
self.skip_test_reason = "%s transport can't connect" % (
- self.transport, )
+ self.transport, )
else:
self.connected = True
@@ -161,14 +161,15 @@ class TransportCase(unittest.TestCase):
return _digest(data).hexdigest()
@skip_if_quick
- def test_produce__consume_large_messages(self, bytes=1048576, n=10,
+ def test_produce__consume_large_messages(
+ self, bytes=1048576, n=10,
charset=string.punctuation + string.letters + string.digits):
if not self.verify_alive():
return
bytes = min(filter(None, [bytes, self.message_size_limit]))
messages = ["".join(random.choice(charset)
- for j in xrange(bytes)) + "--%s" % n
- for i in xrange(n)]
+ for j in xrange(bytes)) + "--%s" % n
+ for i in xrange(n)]
digests = []
chan1 = self.connection.channel()
consumer = chan1.Consumer(self.queue)
@@ -180,7 +181,7 @@ class TransportCase(unittest.TestCase):
digests.append(self._digest(message))
received = [(msg["i"], msg["text"])
- for msg in consumeN(self.connection, consumer, n)]
+ for msg in consumeN(self.connection, consumer, n)]
self.assertEqual(len(received), n)
ordering = [i for i, _ in received]
if ordering != range(n) and not self.suppress_disorder_warning:
@@ -229,8 +230,9 @@ class TransportCase(unittest.TestCase):
chan = self.connection.channel()
self.purge([self.queue.name])
consumer = chan.Consumer(self.queue)
- self.assertRaises(socket.timeout, self.connection.drain_events,
- timeout=0.3)
+ self.assertRaises(
+ socket.timeout, self.connection.drain_events, timeout=0.3,
+ )
consumer.cancel()
chan.close()
diff --git a/kombu/tests/__init__.py b/kombu/tests/__init__.py
index 730d9404..6a13a750 100644
--- a/kombu/tests/__init__.py
+++ b/kombu/tests/__init__.py
@@ -52,12 +52,17 @@ def setup_django_env():
return
if not settings.configured:
- settings.configure(DATABASES={'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': ':memory:'}},
- DATABASE_ENGINE='sqlite3',
- DATABASE_NAME=':memory:',
- INSTALLED_APPS=('kombu.transport.django', ))
+ settings.configure(
+ DATABASES={
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': ':memory:',
+ },
+ },
+ DATABASE_ENGINE='sqlite3',
+ DATABASE_NAME=':memory:',
+ INSTALLED_APPS=('kombu.transport.django', ),
+ )
def setup():
diff --git a/kombu/tests/compat.py b/kombu/tests/compat.py
index 391b7f1a..e750552b 100644
--- a/kombu/tests/compat.py
+++ b/kombu/tests/compat.py
@@ -10,8 +10,8 @@ class WarningMessage(object):
_WARNING_DETAILS = ('message', 'category', 'filename', 'lineno', 'file',
'line')
- def __init__(self, message, category, filename, lineno, file=None,
- line=None):
+ def __init__(self, message, category, filename, lineno,
+ file=None, line=None):
local_values = locals()
for attr in self._WARNING_DETAILS:
setattr(self, attr, local_values[attr])
@@ -20,8 +20,8 @@ class WarningMessage(object):
def __str__(self):
return ('{message : %r, category : %r, filename : %r, lineno : %s, '
- 'line : %r}' % (self.message, self._category_name,
- self.filename, self.lineno, self.line))
+ 'line : %r}' % (self.message, self._category_name,
+ self.filename, self.lineno, self.line))
class catch_warnings(object):
diff --git a/kombu/tests/mocks.py b/kombu/tests/mocks.py
index 16aa4389..4d38da56 100644
--- a/kombu/tests/mocks.py
+++ b/kombu/tests/mocks.py
@@ -42,7 +42,7 @@ class Channel(base.StdChannel):
self._called('exchange_declare')
def prepare_message(self, body, priority=0, content_type=None,
- content_encoding=None, headers=None, properties={}):
+ content_encoding=None, headers=None, properties={}):
self._called('prepare_message')
return dict(body=body,
headers=headers,
@@ -52,7 +52,7 @@ class Channel(base.StdChannel):
content_encoding=content_encoding)
def basic_publish(self, message, exchange='', routing_key='',
- mandatory=False, immediate=False, **kwargs):
+ mandatory=False, immediate=False, **kwargs):
self._called('basic_publish')
return message, exchange, routing_key
@@ -105,9 +105,10 @@ class Channel(base.StdChannel):
def message_to_python(self, message, *args, **kwargs):
self._called('message_to_python')
return Message(self, body=anyjson.dumps(message),
- delivery_tag=self.deliveries(),
- throw_decode_error=self.throw_decode_error,
- content_type='application/json', content_encoding='utf-8')
+ delivery_tag=self.deliveries(),
+ throw_decode_error=self.throw_decode_error,
+ content_type='application/json',
+ content_encoding='utf-8')
def flow(self, active):
self._called('flow')
@@ -118,7 +119,7 @@ class Channel(base.StdChannel):
return self._called('basic_reject')
def basic_qos(self, prefetch_size=0, prefetch_count=0,
- apply_global=False):
+ apply_global=False):
self._called('basic_qos')
diff --git a/kombu/tests/test_common.py b/kombu/tests/test_common.py
index c97fe4ef..978687e3 100644
--- a/kombu/tests/test_common.py
+++ b/kombu/tests/test_common.py
@@ -226,7 +226,8 @@ class test_insured(TestCase):
ret = common.insured(pool, fun, (2, 2), {'foo': 'bar'})
self.assertEqual(ret, 'works')
conn.ensure_connection.assert_called_with(
- errback=common._ensure_errback)
+ errback=common._ensure_errback,
+ )
self.assertTrue(insured.called)
i_args, i_kwargs = insured.call_args
diff --git a/kombu/tests/test_compat.py b/kombu/tests/test_compat.py
index 36a60d39..7e80e21f 100644
--- a/kombu/tests/test_compat.py
+++ b/kombu/tests/test_compat.py
@@ -102,7 +102,7 @@ class test_Publisher(TestCase):
self.assertFalse(pub2.exchange.durable)
explicit = Exchange('test_Publisher_constructor_explicit',
- type='topic')
+ type='topic')
pub3 = compat.Publisher(self.connection,
exchange=explicit)
self.assertEqual(pub3.exchange, explicit)
@@ -241,8 +241,8 @@ class test_Consumer(TestCase):
for i in range(limit):
yield i
- c = C(self.connection, queue=n, exchange=n,
- routing_key='rkey')
+ c = C(self.connection,
+ queue=n, exchange=n, routing_key='rkey')
self.assertEqual(c.wait(10), range(10))
c.close()
@@ -256,8 +256,8 @@ class test_Consumer(TestCase):
i[0] += 1
return z
- c = C(self.connection, queue=n, exchange=n,
- routing_key='rkey')
+ c = C(self.connection,
+ queue=n, exchange=n, routing_key='rkey')
self.assertEqual(list(c.iterqueue(limit=10)), range(10))
c.close()
@@ -289,7 +289,7 @@ class test_ConsumerSet(TestCase):
'routing_key': 'xyz'}}
consumers = [compat.Consumer(self.connection, queue=prefix + str(i),
exchange=prefix + str(i))
- for i in range(3)]
+ for i in range(3)]
c = compat.ConsumerSet(self.connection, consumers=consumers)
c2 = compat.ConsumerSet(self.connection, from_dict=dcon)
@@ -303,9 +303,12 @@ class test_ConsumerSet(TestCase):
for cq in c.queues:
self.assertIs(cq.channel, c.channel)
- c2.add_consumer_from_dict({'%s.xxx' % prefix: {
+ c2.add_consumer_from_dict({
+ '%s.xxx' % prefix: {
'exchange': '%s.xxx' % prefix,
- 'routing_key': 'xxx'}})
+ 'routing_key': 'xxx',
+ },
+ })
self.assertEqual(len(c2.queues), 3)
for c2q in c2.queues:
self.assertIs(c2q.channel, c2.channel)
diff --git a/kombu/tests/test_connection.py b/kombu/tests/test_connection.py
index 6997be69..f3c4120a 100644
--- a/kombu/tests/test_connection.py
+++ b/kombu/tests/test_connection.py
@@ -68,77 +68,78 @@ class test_connection_utils(TestCase):
self.assert_info(
Connection('amqp://user:pass@host:10000/vhost'),
- userid='user', password='pass', hostname='host',
- port=10000, virtual_host='vhost')
+ userid='user', password='pass', hostname='host',
+ port=10000, virtual_host='vhost',
+ )
self.assert_info(
Connection('amqp://user%61:%61pass@ho%61st:10000/v%2fhost'),
- userid='usera', password='apass',
- hostname='hoast', port=10000,
- virtual_host='v/host')
+ userid='usera', password='apass', hostname='hoast',
+ port=10000, virtual_host='v/host',
+ )
self.assert_info(
Connection('amqp://'),
- userid='guest', password='guest',
- hostname='localhost', port=5672,
- virtual_host='/')
+ userid='guest', password='guest', hostname='localhost',
+ port=5672, virtual_host='/',
+ )
self.assert_info(
Connection('amqp://:@/'),
- userid='guest', password='guest',
- hostname='localhost', port=5672,
- virtual_host='/')
+ userid='guest', password='guest', hostname='localhost',
+ port=5672, virtual_host='/',
+ )
self.assert_info(
Connection('amqp://user@/'),
- userid='user', password='guest',
- hostname='localhost', port=5672,
- virtual_host='/')
+ userid='user', password='guest', hostname='localhost',
+ port=5672, virtual_host='/',
+ )
self.assert_info(
Connection('amqp://user:pass@/'),
- userid='user', password='pass',
- hostname='localhost', port=5672,
- virtual_host='/')
+ userid='user', password='pass', hostname='localhost',
+ port=5672, virtual_host='/',
+ )
self.assert_info(
Connection('amqp://host'),
- userid='guest', password='guest',
- hostname='host', port=5672,
- virtual_host='/')
+ userid='guest', password='guest', hostname='host',
+ port=5672, virtual_host='/',
+ )
self.assert_info(
Connection('amqp://:10000'),
- userid='guest', password='guest',
- hostname='localhost', port=10000,
- virtual_host='/')
+ userid='guest', password='guest', hostname='localhost',
+ port=10000, virtual_host='/',
+ )
self.assert_info(
Connection('amqp:///vhost'),
- userid='guest', password='guest',
- hostname='localhost', port=5672,
- virtual_host='vhost')
+ userid='guest', password='guest', hostname='localhost',
+ port=5672, virtual_host='vhost',
+ )
self.assert_info(
Connection('amqp://host/'),
- userid='guest', password='guest',
- hostname='host', port=5672,
- virtual_host='/')
+ userid='guest', password='guest', hostname='host',
+ port=5672, virtual_host='/',
+ )
self.assert_info(
Connection('amqp://host/%2f'),
- userid='guest', password='guest',
- hostname='host', port=5672,
- virtual_host='/')
+ userid='guest', password='guest', hostname='host',
+ port=5672, virtual_host='/',
+ )
def test_url_IPV6(self):
raise SkipTest("urllib can't parse ipv6 urls")
self.assert_info(
Connection('amqp://[::1]'),
- userid='guest', password='guest',
- hostname='[::1]', port=5672,
- virtual_host='/')
+ userid='guest', password='guest', hostname='[::1]',
+ port=5672, virtual_host='/',
+ )
class test_Connection(TestCase):
@@ -635,7 +636,7 @@ class test_ChannelPool(ResourceCase):
def create_resource(self, limit, preload):
return Connection(port=5672, transport=Transport) \
- .ChannelPool(limit, preload)
+ .ChannelPool(limit, preload)
def test_setup(self):
P = self.create_resource(10, 2)
diff --git a/kombu/tests/test_entities.py b/kombu/tests/test_entities.py
index 7c2f25a4..8e89f84e 100644
--- a/kombu/tests/test_entities.py
+++ b/kombu/tests/test_entities.py
@@ -20,7 +20,8 @@ def get_conn():
class test_binding(TestCase):
def test_constructor(self):
- x = binding(Exchange('foo'), 'rkey',
+ x = binding(
+ Exchange('foo'), 'rkey',
arguments={'barg': 'bval'},
unbind_arguments={'uarg': 'uval'},
)
@@ -235,14 +236,16 @@ class test_Queue(TestCase):
])
q(chan).declare()
self.assertIn(
- call(nowait=False,
- exchange='mul1',
- auto_delete=False,
- passive=False,
- arguments=None,
- type='direct',
- durable=True,
- ), chan.exchange_declare.call_args_list,
+ call(
+ nowait=False,
+ exchange='mul1',
+ auto_delete=False,
+ passive=False,
+ arguments=None,
+ type='direct',
+ durable=True,
+ ),
+ chan.exchange_declare.call_args_list,
)
def test_can_cache_declaration(self):
@@ -260,7 +263,8 @@ class test_Queue(TestCase):
def test_exclusive_implies_auto_delete(self):
self.assertTrue(
- Queue('foo', self.exchange, exclusive=True).auto_delete)
+ Queue('foo', self.exchange, exclusive=True).auto_delete,
+ )
def test_binds_at_instantiation(self):
self.assertTrue(Queue('foo', self.exchange,
diff --git a/kombu/tests/test_log.py b/kombu/tests/test_log.py
index 62dd1b35..b9cf966b 100644
--- a/kombu/tests/test_log.py
+++ b/kombu/tests/test_log.py
@@ -80,13 +80,15 @@ class test_LogMixin(TestCase):
def test_error(self):
self.log.error('error', exc_info='exc')
- self.logger.log.assert_called_with(logging.ERROR, 'Log - error',
- exc_info='exc')
+ self.logger.log.assert_called_with(
+ logging.ERROR, 'Log - error', exc_info='exc',
+ )
def test_critical(self):
self.log.critical('crit', exc_info='exc')
- self.logger.log.assert_called_with(logging.CRITICAL, 'Log - crit',
- exc_info='exc')
+ self.logger.log.assert_called_with(
+ logging.CRITICAL, 'Log - crit', exc_info='exc',
+ )
def test_error_when_DISABLE_TRACEBACKS(self):
log.DISABLE_TRACEBACKS = True
@@ -121,8 +123,9 @@ class test_LogMixin(TestCase):
def test_log_with_format(self):
self.log.debug('Host %r removed', 'example.com')
- self.logger.log.assert_called_with(logging.DEBUG,
- 'Log - Host %s removed', "'example.com'")
+ self.logger.log.assert_called_with(
+ logging.DEBUG, 'Log - Host %s removed', "'example.com'",
+ )
class test_setup_logging(TestCase):
diff --git a/kombu/tests/test_messaging.py b/kombu/tests/test_messaging.py
index a6024497..0fb8a657 100644
--- a/kombu/tests/test_messaging.py
+++ b/kombu/tests/test_messaging.py
@@ -87,8 +87,10 @@ class test_Producer(TestCase):
self.assertEqual(cencoding, 'utf-8')
self.assertEqual(headers['compression'], 'application/x-gzip')
import zlib
- self.assertEqual(anyjson.loads(
- zlib.decompress(m).decode('utf-8')), message)
+ self.assertEqual(
+ anyjson.loads(zlib.decompress(m).decode('utf-8')),
+ message,
+ )
def test_prepare_custom_content_type(self):
message = 'the quick brown fox'.encode('utf-8')
@@ -113,7 +115,7 @@ class test_Producer(TestCase):
self.assertEqual(ctype, 'text/plain')
self.assertEqual(cencoding, 'utf-8')
m, ctype, cencoding = p._prepare(message, content_type='text/plain',
- content_encoding='utf-8')
+ content_encoding='utf-8')
self.assertEqual(m, message.encode('utf-8'))
self.assertEqual(ctype, 'text/plain')
self.assertEqual(cencoding, 'utf-8')
diff --git a/kombu/tests/test_pidbox.py b/kombu/tests/test_pidbox.py
index 33e071a7..d250eedb 100644
--- a/kombu/tests/test_pidbox.py
+++ b/kombu/tests/test_pidbox.py
@@ -29,9 +29,11 @@ class test_Mailbox(TestCase):
self.handlers = {'mymethod': self._handler}
self.bound = self.mailbox(self.connection)
self.default_chan = self.connection.channel()
- self.node = self.bound.Node('test_pidbox', state=self.state,
- handlers=self.handlers,
- channel=self.default_chan)
+ self.node = self.bound.Node(
+ 'test_pidbox',
+ state=self.state, handlers=self.handlers,
+ channel=self.default_chan,
+ )
def test_reply__collect(self):
mailbox = pidbox.Mailbox('test_reply__collect')(self.connection)
@@ -46,8 +48,8 @@ class test_Mailbox(TestCase):
def callback(body):
_callback_called[0] = True
- reply = mailbox._collect(ticket, limit=1, callback=callback,
- channel=channel)
+ reply = mailbox._collect(ticket, limit=1,
+ callback=callback, channel=channel)
self.assertEqual(reply, [{'foo': 'bar'}])
self.assertTrue(_callback_called[0])
@@ -209,8 +211,10 @@ class test_Mailbox(TestCase):
self.bound.call('some_node', 'mymethod')
def test_call(self):
- self.assertEqual(self.bound.call(['some_node'], 'mymethod'),
- 'COLLECTED')
+ self.assertEqual(
+ self.bound.call(['some_node'], 'mymethod'),
+ 'COLLECTED',
+ )
consumer = self.node.Consumer()
self.assertIsCall(self.get_next(consumer))
diff --git a/kombu/tests/test_serialization.py b/kombu/tests/test_serialization.py
index c4b8bd81..de7ed343 100644
--- a/kombu/tests/test_serialization.py
+++ b/kombu/tests/test_serialization.py
@@ -22,29 +22,34 @@ latin_string_as_utf8 = latin_string.encode('utf-8')
# For serialization tests
-py_data = {'string': 'The quick brown fox jumps over the lazy dog',
- 'int': 10,
- 'float': 3.14159265,
- 'unicode': u'Thé quick brown fox jumps over thé lazy dog',
- 'list': ['george', 'jerry', 'elaine', 'cosmo'],
+py_data = {
+ 'string': 'The quick brown fox jumps over the lazy dog',
+ 'int': 10,
+ 'float': 3.14159265,
+ 'unicode': u'Thé quick brown fox jumps over thé lazy dog',
+ 'list': ['george', 'jerry', 'elaine', 'cosmo'],
}
# JSON serialization tests
-json_data = ('{"int": 10, "float": 3.1415926500000002, '
- '"list": ["george", "jerry", "elaine", "cosmo"], '
- '"string": "The quick brown fox jumps over the lazy '
- 'dog", "unicode": "Th\\u00e9 quick brown fox jumps over '
- 'th\\u00e9 lazy dog"}')
+json_data = """\
+{"int": 10, "float": 3.1415926500000002, \
+"list": ["george", "jerry", "elaine", "cosmo"], \
+"string": "The quick brown fox jumps over the lazy \
+dog", "unicode": "Th\\u00e9 quick brown fox jumps over \
+th\\u00e9 lazy dog"}\
+"""
# Pickle serialization tests
pickle_data = pickle.dumps(py_data, protocol=pickle_protocol)
# YAML serialization tests
-yaml_data = ('float: 3.1415926500000002\nint: 10\n'
- 'list: [george, jerry, elaine, cosmo]\n'
- 'string: The quick brown fox jumps over the lazy dog\n'
- 'unicode: "Th\\xE9 quick brown fox '
- 'jumps over th\\xE9 lazy dog"\n')
+yaml_data = """\
+float: 3.1415926500000002
+int: 10
+list: [george, jerry, elaine, cosmo]
+string: The quick brown fox jumps over the lazy dog
+unicode: "Th\\xE9 quick brown fox jumps over th\\xE9 lazy dog"
+"""
msgpack_py_data = dict(py_data)
@@ -52,10 +57,12 @@ msgpack_py_data = dict(py_data)
msgpack_py_data['list'] = tuple(msgpack_py_data['list'])
# Unicode chars are lost in transmit :(
msgpack_py_data['unicode'] = 'Th quick brown fox jumps over th lazy dog'
-msgpack_data = ('\x85\xa3int\n\xa5float\xcb@\t!\xfbS\xc8\xd4\xf1\xa4list'
- '\x94\xa6george\xa5jerry\xa6elaine\xa5cosmo\xa6string\xda'
- '\x00+The quick brown fox jumps over the lazy dog\xa7unicode'
- '\xda\x00)Th quick brown fox jumps over th lazy dog')
+msgpack_data = """\
+\x85\xa3int\n\xa5float\xcb@\t!\xfbS\xc8\xd4\xf1\xa4list\
+\x94\xa6george\xa5jerry\xa6elaine\xa5cosmo\xa6string\xda\
+\x00+The quick brown fox jumps over the lazy dog\xa7unicode\
+\xda\x00)Th quick brown fox jumps over th lazy dog\
+"""
def say(m):
@@ -86,11 +93,13 @@ class test_Serialization(TestCase):
registry.disable('testS')
with self.assertRaises(SerializerNotInstalled):
- registry.decode('xxd', 'application/testS', 'utf-8',
- force=False)
+ registry.decode(
+ 'xxd', 'application/testS', 'utf-8', force=False,
+ )
- ret = registry.decode('xxd', 'application/testS', 'utf-8',
- force=True)
+ ret = registry.decode(
+ 'xxd', 'application/testS', 'utf-8', force=True,
+ )
self.assertEqual(ret, 'decoded')
finally:
disabled.clear()
@@ -99,114 +108,142 @@ class test_Serialization(TestCase):
registry.decode(None, 'application/testS', 'utf-8')
def test_content_type_decoding(self):
- self.assertEqual(unicode_string,
- registry.decode(
- unicode_string_as_utf8,
- content_type='plain/text',
- content_encoding='utf-8'))
- self.assertEqual(latin_string,
- registry.decode(
- latin_string_as_latin1,
- content_type='application/data',
- content_encoding='latin-1'))
+ self.assertEqual(
+ unicode_string,
+ registry.decode(unicode_string_as_utf8,
+ content_type='plain/text',
+ content_encoding='utf-8'),
+ )
+ self.assertEqual(
+ latin_string,
+ registry.decode(latin_string_as_latin1,
+ content_type='application/data',
+ content_encoding='latin-1'),
+ )
def test_content_type_binary(self):
- self.assertIsInstance(registry.decode(unicode_string_as_utf8,
- content_type='application/data',
- content_encoding='binary'),
- bytes_t)
-
- self.assertEqual(unicode_string_as_utf8,
- registry.decode(
- unicode_string_as_utf8,
- content_type='application/data',
- content_encoding='binary'))
+ self.assertIsInstance(
+ registry.decode(unicode_string_as_utf8,
+ content_type='application/data',
+ content_encoding='binary'),
+ bytes_t,
+ )
+
+ self.assertEqual(
+ unicode_string_as_utf8,
+ registry.decode(unicode_string_as_utf8,
+ content_type='application/data',
+ content_encoding='binary'),
+ )
def test_content_type_encoding(self):
# Using the 'raw' serializer
- self.assertEqual(unicode_string_as_utf8,
- registry.encode(
- unicode_string, serializer='raw')[-1])
- self.assertEqual(latin_string_as_utf8,
- registry.encode(
- latin_string, serializer='raw')[-1])
+ self.assertEqual(
+ unicode_string_as_utf8,
+ registry.encode(unicode_string, serializer='raw')[-1],
+ )
+ self.assertEqual(
+ latin_string_as_utf8,
+ registry.encode(latin_string, serializer='raw')[-1],
+ )
# And again w/o a specific serializer to check the
# code where we force unicode objects into a string.
- self.assertEqual(unicode_string_as_utf8,
- registry.encode(unicode_string)[-1])
- self.assertEqual(latin_string_as_utf8,
- registry.encode(latin_string)[-1])
+ self.assertEqual(
+ unicode_string_as_utf8,
+ registry.encode(unicode_string)[-1],
+ )
+ self.assertEqual(
+ latin_string_as_utf8,
+ registry.encode(latin_string)[-1],
+ )
def test_json_decode(self):
- self.assertEqual(py_data,
- registry.decode(
- json_data,
- content_type='application/json',
- content_encoding='utf-8'))
+ self.assertEqual(
+ py_data,
+ registry.decode(json_data,
+ content_type='application/json',
+ content_encoding='utf-8'),
+ )
def test_json_encode(self):
- self.assertEqual(registry.decode(
- registry.encode(py_data, serializer='json')[-1],
- content_type='application/json',
- content_encoding='utf-8'),
- registry.decode(
- json_data,
- content_type='application/json',
- content_encoding='utf-8'))
+ self.assertEqual(
+ registry.decode(
+ registry.encode(py_data, serializer='json')[-1],
+ content_type='application/json',
+ content_encoding='utf-8',
+ ),
+ registry.decode(
+ json_data,
+ content_type='application/json',
+ content_encoding='utf-8',
+ ),
+ )
@skip_if_not_module('msgpack')
def test_msgpack_decode(self):
register_msgpack()
- self.assertEqual(msgpack_py_data,
- registry.decode(
- msgpack_data,
- content_type='application/x-msgpack',
- content_encoding='binary'))
+ self.assertEqual(
+ msgpack_py_data,
+ registry.decode(msgpack_data,
+ content_type='application/x-msgpack',
+ content_encoding='binary'),
+ )
@skip_if_not_module('msgpack')
def test_msgpack_encode(self):
register_msgpack()
- self.assertEqual(registry.decode(
+ self.assertEqual(
+ registry.decode(
registry.encode(msgpack_py_data, serializer='msgpack')[-1],
content_type='application/x-msgpack',
- content_encoding='binary'),
- registry.decode(
- msgpack_data,
- content_type='application/x-msgpack',
- content_encoding='binary'))
+ content_encoding='binary',
+ ),
+ registry.decode(
+ msgpack_data,
+ content_type='application/x-msgpack',
+ content_encoding='binary',
+ ),
+ )
@skip_if_not_module('yaml')
def test_yaml_decode(self):
register_yaml()
- self.assertEqual(py_data,
- registry.decode(
- yaml_data,
- content_type='application/x-yaml',
- content_encoding='utf-8'))
+ self.assertEqual(
+ py_data,
+ registry.decode(yaml_data,
+ content_type='application/x-yaml',
+ content_encoding='utf-8'),
+ )
@skip_if_not_module('yaml')
def test_yaml_encode(self):
register_yaml()
- self.assertEqual(registry.decode(
- registry.encode(py_data, serializer='yaml')[-1],
- content_type='application/x-yaml',
- content_encoding='utf-8'),
- registry.decode(
- yaml_data,
- content_type='application/x-yaml',
- content_encoding='utf-8'))
+ self.assertEqual(
+ registry.decode(
+ registry.encode(py_data, serializer='yaml')[-1],
+ content_type='application/x-yaml',
+ content_encoding='utf-8',
+ ),
+ registry.decode(
+ yaml_data,
+ content_type='application/x-yaml',
+ content_encoding='utf-8',
+ ),
+ )
def test_pickle_decode(self):
- self.assertEqual(py_data,
- registry.decode(
- pickle_data,
- content_type='application/x-python-serialize',
- content_encoding='binary'))
+ self.assertEqual(
+ py_data,
+ registry.decode(pickle_data,
+ content_type='application/x-python-serialize',
+ content_encoding='binary'),
+ )
def test_pickle_encode(self):
- self.assertEqual(pickle.loads(pickle_data),
- pickle.loads(registry.encode(py_data,
- serializer='pickle')[-1]))
+ self.assertEqual(
+ pickle.loads(pickle_data),
+ pickle.loads(registry.encode(py_data, serializer='pickle')[-1]),
+ )
def test_register(self):
register(None, None, None, None)
@@ -229,9 +266,10 @@ class test_Serialization(TestCase):
registry.encode('foo', serializer='nonexisting')
def test_raw_encode(self):
- self.assertTupleEqual(raw_encode('foo'.encode('utf-8')),
- ('application/data', 'binary',
- 'foo'.encode('utf-8')))
+ self.assertTupleEqual(
+ raw_encode('foo'.encode('utf-8')),
+ ('application/data', 'binary', 'foo'.encode('utf-8')),
+ )
@mask_modules('yaml')
def test_register_yaml__no_yaml(self):
diff --git a/kombu/tests/test_utils.py b/kombu/tests/test_utils.py
index 3099b337..7090546c 100644
--- a/kombu/tests/test_utils.py
+++ b/kombu/tests/test_utils.py
@@ -65,8 +65,9 @@ class test_utils(TestCase):
self.assertTrue(utils.reprkwargs({'foo': 'bar', 1: 2, u'k': 'v'}))
def test_reprcall(self):
- self.assertTrue(utils.reprcall('add',
- (2, 2), {'copy': True}))
+ self.assertTrue(
+ utils.reprcall('add', (2, 2), {'copy': True}),
+ )
class test_UUID(TestCase):
@@ -142,8 +143,10 @@ class test_emergency_dump_state(TestCase):
def raise_something(*args, **kwargs):
raise KeyError('foo')
- utils.emergency_dump_state({'foo': 'bar'}, open_file=lambda n, m: fh,
- dump=raise_something)
+ utils.emergency_dump_state(
+ {'foo': 'bar'},
+ open_file=lambda n, m: fh, dump=raise_something,
+ )
self.assertIn("'foo': 'bar'", fh.getvalue())
self.assertTrue(stderr.getvalue())
self.assertFalse(stdout.getvalue())
@@ -192,12 +195,13 @@ class test_retry_over_time(TestCase):
try:
utils.count.return_value = range(1)
x = utils.retry_over_time(self.myfun, self.Predicate,
- errback=None, interval_max=14)
+ errback=None, interval_max=14)
self.assertIsNone(x)
utils.count.return_value = range(10)
cb = Mock()
x = utils.retry_over_time(self.myfun, self.Predicate,
- errback=self.errback, callback=cb, interval_max=14)
+ errback=self.errback, callback=cb,
+ interval_max=14)
self.assertEqual(x, 42)
self.assertEqual(self.index, 9)
cb.assert_called_with()
@@ -206,20 +210,26 @@ class test_retry_over_time(TestCase):
@insomnia
def test_retry_once(self):
- self.assertRaises(self.Predicate, utils.retry_over_time,
- self.myfun, self.Predicate,
- max_retries=1, errback=self.errback, interval_max=14)
+ self.assertRaises(
+ self.Predicate, utils.retry_over_time,
+ self.myfun, self.Predicate,
+ max_retries=1, errback=self.errback, interval_max=14,
+ )
self.assertEqual(self.index, 2)
# no errback
- self.assertRaises(self.Predicate, utils.retry_over_time,
- self.myfun, self.Predicate,
- max_retries=1, errback=None, interval_max=14)
+ self.assertRaises(
+ self.Predicate, utils.retry_over_time,
+ self.myfun, self.Predicate,
+ max_retries=1, errback=None, interval_max=14,
+ )
@insomnia
def test_retry_never(self):
- self.assertRaises(self.Predicate, utils.retry_over_time,
- self.myfun, self.Predicate,
- max_retries=0, errback=self.errback, interval_max=14)
+ self.assertRaises(
+ self.Predicate, utils.retry_over_time,
+ self.myfun, self.Predicate,
+ max_retries=0, errback=self.errback, interval_max=14,
+ )
self.assertEqual(self.index, 1)
@@ -281,8 +291,10 @@ class test_symbol_by_name(TestCase):
def test_returns_default(self):
default = object()
- self.assertIs(utils.symbol_by_name('xyz.ryx.qedoa.weq:foz',
- default=default), default)
+ self.assertIs(
+ utils.symbol_by_name('xyz.ryx.qedoa.weq:foz', default=default),
+ default,
+ )
def test_no_default(self):
with self.assertRaises(ImportError):
@@ -296,16 +308,20 @@ class test_symbol_by_name(TestCase):
def test_package(self):
from kombu.entity import Exchange
- self.assertIs(utils.symbol_by_name('.entity:Exchange',
- package='kombu'), Exchange)
+ self.assertIs(
+ utils.symbol_by_name('.entity:Exchange', package='kombu'),
+ Exchange,
+ )
self.assertTrue(utils.symbol_by_name(':Consumer', package='kombu'))
class test_ChannelPromise(TestCase):
def test_repr(self):
- self.assertEqual(repr(utils.ChannelPromise(lambda: 'foo')),
- "<promise: 'foo'>")
+ self.assertEqual(
+ repr(utils.ChannelPromise(lambda: 'foo')),
+ "<promise: 'foo'>",
+ )
class test_entrypoints(TestCase):
diff --git a/kombu/tests/transport/test_amqplib.py b/kombu/tests/transport/test_amqplib.py
index fb6c0141..185cc349 100644
--- a/kombu/tests/transport/test_amqplib.py
+++ b/kombu/tests/transport/test_amqplib.py
@@ -57,10 +57,10 @@ class test_Channel(amqplibCase):
self.assertFalse(self.channel.no_ack_consumers)
def test_prepare_message(self):
- x = self.channel.prepare_message('foobar', 10,
- 'application/data', 'utf-8',
- properties={})
- self.assertTrue(x)
+ self.assertTrue(self.channel.prepare_message(
+ 'foobar', 10, 'application/data', 'utf-8',
+ properties={},
+ ))
def test_message_to_python(self):
message = Mock()
diff --git a/kombu/tests/transport/test_base.py b/kombu/tests/transport/test_base.py
index e369449f..c34871d7 100644
--- a/kombu/tests/transport/test_base.py
+++ b/kombu/tests/transport/test_base.py
@@ -33,8 +33,9 @@ class test_StdChannel(TestCase):
StdChannel().get_bindings()
def test_interface_after_reply_message_received(self):
- self.assertIsNone(StdChannel().after_reply_message_received(
- Queue('foo')))
+ self.assertIsNone(
+ StdChannel().after_reply_message_received(Queue('foo')),
+ )
class test_Message(TestCase):
diff --git a/kombu/tests/transport/test_pyamqp.py b/kombu/tests/transport/test_pyamqp.py
index a1b550da..bd4e86bf 100644
--- a/kombu/tests/transport/test_pyamqp.py
+++ b/kombu/tests/transport/test_pyamqp.py
@@ -50,10 +50,10 @@ class test_Channel(TestCase):
self.assertFalse(self.channel.no_ack_consumers)
def test_prepare_message(self):
- x = self.channel.prepare_message('foobar', 10,
- 'application/data', 'utf-8',
- properties={})
- self.assertTrue(x)
+ self.assertTrue(self.channel.prepare_message(
+ 'foobar', 10, 'application/data', 'utf-8',
+ properties={},
+ ))
def test_message_to_python(self):
message = Mock()
@@ -166,8 +166,10 @@ class test_pyamqp(TestCase):
def test_eventmap(self):
t = pyamqp.Transport(Mock())
conn = Mock()
- self.assertDictEqual(t.eventmap(conn),
- {conn.sock: t.client.drain_nowait})
+ self.assertDictEqual(
+ t.eventmap(conn),
+ {conn.sock: t.client.drain_nowait},
+ )
def test_event_interface(self):
t = pyamqp.Transport(Mock())
diff --git a/kombu/tests/transport/test_redis.py b/kombu/tests/transport/test_redis.py
index e007664d..90e3a318 100644
--- a/kombu/tests/transport/test_redis.py
+++ b/kombu/tests/transport/test_redis.py
@@ -262,22 +262,32 @@ class test_Channel(TestCase):
self.assertFalse(s.subscribed)
def test_handle_pmessage_message(self):
- self.assertDictEqual(self.channel._handle_message(
- self.channel.subclient,
- ['pmessage', 'pattern', 'channel', 'data']),
- {'type': 'pmessage',
- 'pattern': 'pattern',
- 'channel': 'channel',
- 'data': 'data'})
+ self.assertDictEqual(
+ self.channel._handle_message(
+ self.channel.subclient,
+ ['pmessage', 'pattern', 'channel', 'data'],
+ ),
+ {
+ 'type': 'pmessage',
+ 'pattern': 'pattern',
+ 'channel': 'channel',
+ 'data': 'data',
+ },
+ )
def test_handle_message(self):
- self.assertDictEqual(self.channel._handle_message(
- self.channel.subclient,
- ['type', 'channel', 'data']),
- {'type': 'type',
- 'pattern': None,
- 'channel': 'channel',
- 'data': 'data'})
+ self.assertDictEqual(
+ self.channel._handle_message(
+ self.channel.subclient,
+ ['type', 'channel', 'data'],
+ ),
+ {
+ 'type': 'type',
+ 'pattern': None,
+ 'channel': 'channel',
+ 'data': 'data',
+ },
+ )
def test_brpop_start_but_no_queues(self):
self.assertIsNone(self.channel._brpop_start())
@@ -725,8 +735,7 @@ class test_MultiChannelPoller(TestCase):
self.assertEqual(p._register.call_count, 1)
self.assertEqual(channel._subscribe.call_count, 1)
- def create_get(self, events=None, queues=None,
- fanouts=None):
+ def create_get(self, events=None, queues=None, fanouts=None):
_pr = [] if events is None else events
_aq = [] if queues is None else queues
_af = [] if fanouts is None else fanouts
diff --git a/kombu/tests/transport/virtual/test_base.py b/kombu/tests/transport/virtual/test_base.py
index 4adfa9e6..736063dc 100644
--- a/kombu/tests/transport/virtual/test_base.py
+++ b/kombu/tests/transport/virtual/test_base.py
@@ -286,7 +286,7 @@ class test_Channel(TestCase):
self.assertIn(n, c.purged)
def test_basic_publish__get__consume__restore(self,
- n='test_basic_publish'):
+ n='test_basic_publish'):
c = memory_client().channel()
c.exchange_declare(n)
@@ -306,8 +306,8 @@ class test_Channel(TestCase):
consumer_tag = uuid()
- c.basic_consume(n + '2', False, consumer_tag=consumer_tag,
- callback=lambda *a: None)
+ c.basic_consume(n + '2', False,
+ consumer_tag=consumer_tag, callback=lambda *a: None)
self.assertIn(n + '2', c._active_queues)
r2, _ = c.drain_events()
r2 = c.message_to_python(r2)
@@ -365,7 +365,7 @@ class test_Channel(TestCase):
@patch('kombu.transport.virtual.emergency_dump_state')
@patch('kombu.transport.virtual.say')
def test_restore_unacked_once_when_unrestored(self, say,
- emergency_dump_state):
+ emergency_dump_state):
q = self.channel.qos
q._flush = Mock()
@@ -409,8 +409,10 @@ class test_Channel(TestCase):
def test_lookup__undeliverable(self, n='test_lookup__undeliverable'):
warnings.resetwarnings()
with catch_warnings(record=True) as log:
- self.assertListEqual(self.channel._lookup(n, n, 'ae.undeliver'),
- ['ae.undeliver'])
+ self.assertListEqual(
+ self.channel._lookup(n, n, 'ae.undeliver'),
+ ['ae.undeliver'],
+ )
self.assertTrue(log)
self.assertIn('could not be delivered', log[0].message.args[0])
diff --git a/kombu/tests/transport/virtual/test_exchange.py b/kombu/tests/transport/virtual/test_exchange.py
index d1b2a85a..90127ba0 100644
--- a/kombu/tests/transport/virtual/test_exchange.py
+++ b/kombu/tests/transport/virtual/test_exchange.py
@@ -25,15 +25,18 @@ class test_Direct(ExchangeCase):
('rBaz', None, 'qBaz')]
def test_lookup(self):
- self.assertListEqual(self.e.lookup(
- self.table, 'eFoo', 'rFoo', None),
- ['qFoo', 'qFox'])
- self.assertListEqual(self.e.lookup(
- self.table, 'eMoz', 'rMoz', 'DEFAULT'),
- [])
- self.assertListEqual(self.e.lookup(
- self.table, 'eBar', 'rBar', None),
- ['qBar'])
+ self.assertListEqual(
+ self.e.lookup(self.table, 'eFoo', 'rFoo', None),
+ ['qFoo', 'qFox'],
+ )
+ self.assertListEqual(
+ self.e.lookup(self.table, 'eMoz', 'rMoz', 'DEFAULT'),
+ [],
+ )
+ self.assertListEqual(
+ self.e.lookup(self.table, 'eBar', 'rBar', None),
+ ['qBar'],
+ )
class test_Fanout(ExchangeCase):
@@ -43,9 +46,10 @@ class test_Fanout(ExchangeCase):
(None, None, 'qBar')]
def test_lookup(self):
- self.assertListEqual(self.e.lookup(
- self.table, 'eFoo', 'rFoo', None),
- ['qFoo', 'qFox', 'qBar'])
+ self.assertListEqual(
+ self.e.lookup(self.table, 'eFoo', 'rFoo', None),
+ ['qFoo', 'qFox', 'qBar'],
+ )
def test_deliver_when_fanout_supported(self):
self.e.channel = Mock()
@@ -65,32 +69,39 @@ class test_Fanout(ExchangeCase):
class test_Topic(ExchangeCase):
type = exchange.TopicExchange
- table = [('stock.#', None, 'rFoo'),
- ('stock.us.*', None, 'rBar')]
+ table = [
+ ('stock.#', None, 'rFoo'),
+ ('stock.us.*', None, 'rBar'),
+ ]
def setUp(self):
super(test_Topic, self).setUp()
self.table = [(rkey, self.e.key_to_pattern(rkey), queue)
- for rkey, _, queue in self.table]
+ for rkey, _, queue in self.table]
def test_prepare_bind(self):
x = self.e.prepare_bind('qFoo', 'eFoo', 'stock.#', {})
self.assertTupleEqual(x, ('stock.#', r'^stock\..*?$', 'qFoo'))
def test_lookup(self):
- self.assertListEqual(self.e.lookup(
- self.table, 'eFoo', 'stock.us.nasdaq', None),
- ['rFoo', 'rBar'])
+ self.assertListEqual(
+ self.e.lookup(self.table, 'eFoo', 'stock.us.nasdaq', None),
+ ['rFoo', 'rBar'],
+ )
self.assertTrue(self.e._compiled)
- self.assertListEqual(self.e.lookup(
- self.table, 'eFoo', 'stock.europe.OSE', None),
- ['rFoo'])
- self.assertListEqual(self.e.lookup(
- self.table, 'eFoo', 'stockxeuropexOSE', None),
- [])
- self.assertListEqual(self.e.lookup(
- self.table, 'eFoo', 'candy.schleckpulver.snap_crackle', None),
- [])
+ self.assertListEqual(
+ self.e.lookup(self.table, 'eFoo', 'stock.europe.OSE', None),
+ ['rFoo'],
+ )
+ self.assertListEqual(
+ self.e.lookup(self.table, 'eFoo', 'stockxeuropexOSE', None),
+ [],
+ )
+ self.assertListEqual(
+ self.e.lookup(self.table, 'eFoo',
+ 'candy.schleckpulver.snap_crackle', None),
+ [],
+ )
def test_deliver(self):
self.e.channel = Mock()
@@ -111,29 +122,40 @@ class test_ExchangeType(ExchangeCase):
self.e.lookup([], 'eFoo', 'rFoo', None)
def test_prepare_bind(self):
- self.assertTupleEqual(self.e.prepare_bind('qFoo', 'eFoo', 'rFoo', {}),
- ('rFoo', None, 'qFoo'))
+ self.assertTupleEqual(
+ self.e.prepare_bind('qFoo', 'eFoo', 'rFoo', {}),
+ ('rFoo', None, 'qFoo'),
+ )
def test_equivalent(self):
- e1 = dict(type='direct',
- durable=True,
- auto_delete=True,
- arguments={})
+ e1 = dict(
+ type='direct',
+ durable=True,
+ auto_delete=True,
+ arguments={},
+ )
self.assertTrue(
- self.e.equivalent(e1, 'eFoo', 'direct', True, True, {}))
+ self.e.equivalent(e1, 'eFoo', 'direct', True, True, {}),
+ )
self.assertFalse(
- self.e.equivalent(e1, 'eFoo', 'topic', True, True, {}))
+ self.e.equivalent(e1, 'eFoo', 'topic', True, True, {}),
+ )
self.assertFalse(
- self.e.equivalent(e1, 'eFoo', 'direct', False, True, {}))
+ self.e.equivalent(e1, 'eFoo', 'direct', False, True, {}),
+ )
self.assertFalse(
- self.e.equivalent(e1, 'eFoo', 'direct', True, False, {}))
+ self.e.equivalent(e1, 'eFoo', 'direct', True, False, {}),
+ )
self.assertFalse(
- self.e.equivalent(e1, 'eFoo', 'direct', True, True, {
- 'expires': 3000}))
+ self.e.equivalent(e1, 'eFoo', 'direct', True, True,
+ {'expires': 3000}),
+ )
e2 = dict(e1, arguments={'expires': 3000})
self.assertTrue(
- self.e.equivalent(e2, 'eFoo', 'direct', True, True, {
- 'expires': 3000}))
+ self.e.equivalent(e2, 'eFoo', 'direct', True, True,
+ {'expires': 3000}),
+ )
self.assertFalse(
- self.e.equivalent(e2, 'eFoo', 'direct', True, True, {
- 'expires': 6000}))
+ self.e.equivalent(e2, 'eFoo', 'direct', True, True,
+ {'expires': 6000}),
+ )
diff --git a/kombu/tests/transport/virtual/test_scheduling.py b/kombu/tests/transport/virtual/test_scheduling.py
index afbcd061..6f2d24f1 100644
--- a/kombu/tests/transport/virtual/test_scheduling.py
+++ b/kombu/tests/transport/virtual/test_scheduling.py
@@ -43,12 +43,16 @@ class test_FairCycle(TestCase):
return r
cycle = FairCycle(echo, resources, MyEmpty)
- self.assertEqual(consume(cycle.get, len(resources)),
- [('a', 'a'), ('b', 'b'), ('d', 'd'),
- ('e', 'e'), ('a', 'a')])
- self.assertEqual(consume(cycle.get, len(resources)),
- [('b', 'b'), ('d', 'd'), ('e', 'e'),
- ('a', 'a'), ('b', 'b')])
+ self.assertEqual(
+ consume(cycle.get, len(resources)),
+ [('a', 'a'), ('b', 'b'), ('d', 'd'),
+ ('e', 'e'), ('a', 'a')],
+ )
+ self.assertEqual(
+ consume(cycle.get, len(resources)),
+ [('b', 'b'), ('d', 'd'), ('e', 'e'),
+ ('a', 'a'), ('b', 'b')],
+ )
cycle2 = FairCycle(echo, ['c', 'c'], MyEmpty)
with self.assertRaises(MyEmpty):
consume(cycle2.get, 3)
diff --git a/kombu/tests/utilities/test_amq_manager.py b/kombu/tests/utilities/test_amq_manager.py
index 1dcd761b..ccf4ec08 100644
--- a/kombu/tests/utilities/test_amq_manager.py
+++ b/kombu/tests/utilities/test_amq_manager.py
@@ -19,8 +19,9 @@ class test_get_manager(TestCase):
with patch('pyrabbit.Client', create=True) as Client:
manager = Connection('amqp://').get_manager()
self.assertIsNotNone(manager)
- Client.assert_called_with('localhost:55672',
- 'guest', 'guest')
+ Client.assert_called_with(
+ 'localhost:55672', 'guest', 'guest',
+ )
@module_exists('pyrabbit')
def test_transport_options(self):
@@ -32,5 +33,6 @@ class test_get_manager(TestCase):
'manager_password': 'bosco',
}).get_manager()
self.assertIsNotNone(manager)
- Client.assert_called_with('admin.mq.vandelay.com:808',
- 'george', 'bosco')
+ Client.assert_called_with(
+ 'admin.mq.vandelay.com:808', 'george', 'bosco',
+ )
diff --git a/kombu/tests/utilities/test_functional.py b/kombu/tests/utilities/test_functional.py
index c84a6854..b20ad5b7 100644
--- a/kombu/tests/utilities/test_functional.py
+++ b/kombu/tests/utilities/test_functional.py
@@ -14,12 +14,16 @@ def double(x):
class test_promise(TestCase):
def test__str__(self):
- self.assertEqual(str(promise(lambda: 'the quick brown fox')),
- 'the quick brown fox')
+ self.assertEqual(
+ str(promise(lambda: 'the quick brown fox')),
+ 'the quick brown fox',
+ )
def test__repr__(self):
- self.assertEqual(repr(promise(lambda: 'fi fa fo')),
- "'fi fa fo'")
+ self.assertEqual(
+ repr(promise(lambda: 'fi fa fo')),
+ "'fi fa fo'",
+ )
def test_evaluate(self):
self.assertEqual(promise(lambda: 2 + 2)(), 4)
diff --git a/kombu/tests/utils.py b/kombu/tests/utils.py
index 61c98b66..a8f92a37 100644
--- a/kombu/tests/utils.py
+++ b/kombu/tests/utils.py
@@ -60,8 +60,8 @@ def redirect_stdouts(fun):
sys.stdout = StringIO()
sys.stderr = StringIO()
try:
- return fun(*args, **dict(kwargs, stdout=sys.stdout,
- stderr=sys.stderr))
+ return fun(*args, **dict(kwargs,
+ stdout=sys.stdout, stderr=sys.stderr))
finally:
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
diff --git a/pavement.py b/pavement.py
index a51cca73..ba467adb 100644
--- a/pavement.py
+++ b/pavement.py
@@ -7,7 +7,7 @@ from paver.setuputils import setup # noqa
PYCOMPILE_CACHES = ["*.pyc", "*$py.class"]
options(
- sphinx=Bunch(builddir=".build"),
+ sphinx=Bunch(builddir=".build"),
)
@@ -91,7 +91,7 @@ def readme(options):
])
def bump(options):
s = "-- '%s'" % (options.custom, ) \
- if getattr(options, "custom", None) else ""
+ if getattr(options, "custom", None) else ""
sh("extra/release/bump_version.py \
kombu/__init__.py README.rst %s" % (s, ))
@@ -129,6 +129,7 @@ def flake8(options):
}{exit $FOUND_FLAKE;
'""" % (complexity, migrations_path), ignore_error=noerror)
+
@task
@cmdopts([
("noerror", "E", "Ignore errors"),
diff --git a/setup.py b/setup.py
index d512407f..1adf5b09 100644
--- a/setup.py
+++ b/setup.py
@@ -88,8 +88,9 @@ for dirpath, dirnames, filenames in os.walk(src_dir):
if filename.endswith('.py'):
packages.append('.'.join(fullsplit(dirpath)))
else:
- data_files.append([dirpath, [os.path.join(dirpath, f) for f in
- filenames]])
+ data_files.append(
+ [dirpath, [os.path.join(dirpath, f) for f in filenames]],
+ )
if os.path.exists('README.rst'):
long_description = codecs.open('README.rst', 'r', 'utf-8').read()