Small changes to #598

This commit is contained in:
Ask Solem 2016-09-07 17:33:49 -07:00
parent 74f0180576
commit ed783a02ef
1 changed files with 5 additions and 12 deletions

View File

@ -13,22 +13,17 @@ from case.skip import SkipTest
from kombu import Connection from kombu import Connection
from kombu import Exchange, Queue from kombu import Exchange, Queue
from kombu.five import range from kombu.five import buffer_t, range
from kombu.utils.encoding import str_to_bytes
if sys.version_info >= (2, 5): if sys.version_info >= (2, 5):
from hashlib import sha256 as _digest from hashlib import sha256 as _digest
else: else:
from sha import new as _digest # noqa from sha import new as _digest # noqa
if not hasattr(string, 'letters'):
string.letters = string.ascii_letters
def _nobuf(x): def _nobuf(x):
if 'buffer' in locals(): return [str(i) if isinstance(i, buffer_t) else i for i in x]
return [str(i) if isinstance(i, buffer) else i for i in x]
else:
return [str(i) for i in x]
def consumeN(conn, consumer, n=1, timeout=30): def consumeN(conn, consumer, n=1, timeout=30):
@ -167,13 +162,11 @@ class TransportCase(unittest.TestCase):
purged += self.purge_consumer(consumer) purged += self.purge_consumer(consumer)
def _digest(self, data): def _digest(self, data):
if isinstance(data, type(u'')): return _digest(str_to_bytes(data)).hexdigest()
data = data.encode()
return _digest(data).hexdigest()
def test_produce__consume_large_messages( def test_produce__consume_large_messages(
self, bytes=1048576, n=10, self, bytes=1048576, n=10,
charset=string.punctuation + string.letters + string.digits): charset=string.punctuation + string.ascii_letters + string.digits):
if not self.verify_alive(): if not self.verify_alive():
return return
bytes = min(x for x in [bytes, self.message_size_limit] if x) bytes = min(x for x in [bytes, self.message_size_limit] if x)