diff options
author | Dana Powers <dana.powers@rd.io> | 2014-09-07 18:52:05 -0700 |
---|---|---|
committer | Dana Powers <dana.powers@rd.io> | 2014-09-07 19:09:32 -0700 |
commit | 715425c639a476139065689afde3d255a07d6f96 (patch) | |
tree | 0ef2cd875c97c8ca867d89328d6fd5fec7dfcbe8 /test/testutil.py | |
parent | a99384f4c601d127ab1c4fe5b272ea5c07fd695d (diff) | |
parent | be23042ecd9ab330886745ccc9ec9e3a0039836f (diff) | |
download | kafka-python-715425c639a476139065689afde3d255a07d6f96.tar.gz |
Merge pull request #227 from wizzat-feature/py3
Python 3 Support
Conflicts:
kafka/producer.py
test/test_client.py
test/test_client_integration.py
test/test_codec.py
test/test_consumer.py
test/test_consumer_integration.py
test/test_failover_integration.py
test/test_producer.py
test/test_producer_integration.py
test/test_protocol.py
test/test_util.py
Diffstat (limited to 'test/testutil.py')
-rw-r--r-- | test/testutil.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/test/testutil.py b/test/testutil.py index dc8eea0..fba3869 100644 --- a/test/testutil.py +++ b/test/testutil.py @@ -5,11 +5,13 @@ import random import socket import string import time -import unittest2 import uuid -from kafka.common import OffsetRequest +from six.moves import xrange +from . import unittest + from kafka import KafkaClient +from kafka.common import OffsetRequest __all__ = [ 'random_string', @@ -20,8 +22,8 @@ __all__ = [ ] def random_string(l): - s = "".join(random.choice(string.letters) for i in xrange(l)) - return s + s = "".join(random.choice(string.ascii_letters) for i in xrange(l)) + return s.encode('utf-8') def kafka_versions(*versions): def kafka_versions(func): @@ -45,7 +47,7 @@ def get_open_port(): sock.close() return port -class KafkaIntegrationTestCase(unittest2.TestCase): +class KafkaIntegrationTestCase(unittest.TestCase): create_client = True topic = None server = None @@ -56,7 +58,8 @@ class KafkaIntegrationTestCase(unittest2.TestCase): return if not self.topic: - self.topic = "%s-%s" % (self.id()[self.id().rindex(".") + 1:], random_string(10)) + topic = "%s-%s" % (self.id()[self.id().rindex(".") + 1:], random_string(10).decode('utf-8')) + self.topic = topic.encode('utf-8') if self.create_client: self.client = KafkaClient('%s:%d' % (self.server.host, self.server.port)) @@ -84,7 +87,7 @@ class KafkaIntegrationTestCase(unittest2.TestCase): if s not in self._messages: self._messages[s] = '%s-%s-%s' % (s, self.id(), str(uuid.uuid4())) - return self._messages[s] + return self._messages[s].encode('utf-8') class Timer(object): def __enter__(self): |