From 83af5102e995e854a1980b90f1400afdd098da37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Reni=C3=A9?= Date: Thu, 28 Aug 2014 14:40:01 +0200 Subject: Use base unittest or unittest2 depending on python version --- test/testutil.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test/testutil.py') diff --git a/test/testutil.py b/test/testutil.py index dc8eea0..e7dcda6 100644 --- a/test/testutil.py +++ b/test/testutil.py @@ -5,9 +5,10 @@ import random import socket import string import time -import unittest2 import uuid +from . import unittest + from kafka.common import OffsetRequest from kafka import KafkaClient @@ -45,7 +46,7 @@ def get_open_port(): sock.close() return port -class KafkaIntegrationTestCase(unittest2.TestCase): +class KafkaIntegrationTestCase(unittest.TestCase): create_client = True topic = None server = None -- cgit v1.2.1 From cf0b7f0530e765f2cf710bd35daf53bb4ea205d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Reni=C3=A9?= Date: Thu, 28 Aug 2014 20:50:20 +0200 Subject: Make all unit tests pass on py3.3/3.4 --- test/testutil.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test/testutil.py') diff --git a/test/testutil.py b/test/testutil.py index e7dcda6..8584509 100644 --- a/test/testutil.py +++ b/test/testutil.py @@ -7,6 +7,8 @@ import string import time import uuid +from six.moves import xrange + from . import unittest from kafka.common import OffsetRequest @@ -21,8 +23,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): -- cgit v1.2.1 From 8a54974e5676002fffc0fdbb9b5d6ee7dc9f3a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Reni=C3=A9?= Date: Thu, 28 Aug 2014 22:36:38 +0200 Subject: Topic in bytes --- test/testutil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/testutil.py') diff --git a/test/testutil.py b/test/testutil.py index 8584509..5cdebb3 100644 --- a/test/testutil.py +++ b/test/testutil.py @@ -64,7 +64,7 @@ class KafkaIntegrationTestCase(unittest.TestCase): if self.create_client: self.client = KafkaClient('%s:%d' % (self.server.host, self.server.port)) - self.client.ensure_topic_exists(self.topic) + self.client.ensure_topic_exists(self.topic.encode('utf-8')) self._messages = {} -- cgit v1.2.1 From 85785bbce311973ee6161e56dac23a08427cec8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Reni=C3=A9?= Date: Fri, 29 Aug 2014 09:27:55 +0200 Subject: Fix bytes interpolation --- test/testutil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/testutil.py') diff --git a/test/testutil.py b/test/testutil.py index 5cdebb3..980a683 100644 --- a/test/testutil.py +++ b/test/testutil.py @@ -59,7 +59,7 @@ class KafkaIntegrationTestCase(unittest.TestCase): return if not self.topic: - self.topic = "%s-%s" % (self.id()[self.id().rindex(".") + 1:], random_string(10)) + self.topic = "%s-%s" % (self.id()[self.id().rindex(".") + 1:], random_string(10).decode('utf-8')) if self.create_client: self.client = KafkaClient('%s:%d' % (self.server.host, self.server.port)) -- cgit v1.2.1 From 974cda1b7ad21ae6c2e7f2f03d5f87d8061c143b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Reni=C3=A9?= Date: Fri, 29 Aug 2014 09:44:41 +0200 Subject: Encode topic directly --- test/testutil.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/testutil.py') diff --git a/test/testutil.py b/test/testutil.py index 980a683..7c8c802 100644 --- a/test/testutil.py +++ b/test/testutil.py @@ -60,11 +60,12 @@ class KafkaIntegrationTestCase(unittest.TestCase): if not self.topic: self.topic = "%s-%s" % (self.id()[self.id().rindex(".") + 1:], random_string(10).decode('utf-8')) + self.topic = self.topic.encode('utf-8') if self.create_client: self.client = KafkaClient('%s:%d' % (self.server.host, self.server.port)) - self.client.ensure_topic_exists(self.topic.encode('utf-8')) + self.client.ensure_topic_exists(self.topic) self._messages = {} -- cgit v1.2.1 From ab80fa8283dc938e354d094e34fb0e86b5316ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Reni=C3=A9?= Date: Fri, 29 Aug 2014 10:26:36 +0200 Subject: Bytes in self.msg() --- test/testutil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/testutil.py') diff --git a/test/testutil.py b/test/testutil.py index 7c8c802..114dff9 100644 --- a/test/testutil.py +++ b/test/testutil.py @@ -88,7 +88,7 @@ class KafkaIntegrationTestCase(unittest.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): -- cgit v1.2.1 From 81f51b9b284d750f5e5added2f2c4bd773acd604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Reni=C3=A9?= Date: Fri, 29 Aug 2014 15:23:48 +0200 Subject: Fix more tests, only multiprocessing consumer ones remaining --- test/testutil.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/testutil.py') diff --git a/test/testutil.py b/test/testutil.py index 114dff9..9262fca 100644 --- a/test/testutil.py +++ b/test/testutil.py @@ -59,8 +59,8 @@ class KafkaIntegrationTestCase(unittest.TestCase): return if not self.topic: - self.topic = "%s-%s" % (self.id()[self.id().rindex(".") + 1:], random_string(10).decode('utf-8')) - self.topic = self.topic.encode('utf-8') + 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)) -- cgit v1.2.1