diff options
author | Space <space@wibidata.com> | 2015-03-31 15:25:38 -0700 |
---|---|---|
committer | Space <space@wibidata.com> | 2015-04-03 10:23:39 -0700 |
commit | 1c856e8400e1c4fe6dccd562fbcf4d1bde38755d (patch) | |
tree | 69e8a5142d8946adddc44590612a9968540d801f /test/testutil.py | |
parent | 9fd08119170b64c56ea024d12ef6b0e6482d778b (diff) | |
download | kafka-python-1c856e8400e1c4fe6dccd562fbcf4d1bde38755d.tar.gz |
Make external API consistently support python3 strings for topic.
Diffstat (limited to 'test/testutil.py')
-rw-r--r-- | test/testutil.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/testutil.py b/test/testutil.py index 7661cbc..e6947b4 100644 --- a/test/testutil.py +++ b/test/testutil.py @@ -12,6 +12,7 @@ from . import unittest from kafka import KafkaClient from kafka.common import OffsetRequest +from kafka.util import kafka_bytestring __all__ = [ 'random_string', @@ -50,6 +51,7 @@ def get_open_port(): class KafkaIntegrationTestCase(unittest.TestCase): create_client = True topic = None + bytes_topic = None server = None def setUp(self): @@ -59,7 +61,8 @@ class KafkaIntegrationTestCase(unittest.TestCase): if not self.topic: topic = "%s-%s" % (self.id()[self.id().rindex(".") + 1:], random_string(10).decode('utf-8')) - self.topic = topic.encode('utf-8') + self.topic = topic + self.bytes_topic = topic.encode('utf-8') if self.create_client: self.client = KafkaClient('%s:%d' % (self.server.host, self.server.port)) @@ -77,7 +80,8 @@ class KafkaIntegrationTestCase(unittest.TestCase): self.client.close() def current_offset(self, topic, partition): - offsets, = self.client.send_offset_request([ OffsetRequest(topic, partition, -1, 1) ]) + offsets, = self.client.send_offset_request([ OffsetRequest(kafka_bytestring(topic), + partition, -1, 1) ]) return offsets.offsets[0] def msgs(self, iterable): |