summaryrefslogtreecommitdiff
path: root/test/testutil.py
diff options
context:
space:
mode:
authorMark Roberts <wizzat@gmail.com>2014-04-17 17:43:38 -0700
committerMark Roberts <wizzat@gmail.com>2014-04-17 17:43:38 -0700
commit1984dab59f8b6c39aeaeec383c68fffeea59d9d6 (patch)
tree4764bcd06c92d884563414fdf8eacde298495d05 /test/testutil.py
parent8983e73437e485d1da30cc12dbf2e78bfada356c (diff)
downloadkafka-python-1984dab59f8b6c39aeaeec383c68fffeea59d9d6.tar.gz
Finish breaking out integration tests
Diffstat (limited to 'test/testutil.py')
-rw-r--r--test/testutil.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/test/testutil.py b/test/testutil.py
index 4866b9d..2cf62eb 100644
--- a/test/testutil.py
+++ b/test/testutil.py
@@ -26,6 +26,7 @@ def ensure_topic_creation(client, topic_name, timeout = 30):
time.sleep(1)
class KafkaIntegrationTestCase(unittest.TestCase):
+ create_client = True
topic = None
def setUp(self):
@@ -33,13 +34,17 @@ class KafkaIntegrationTestCase(unittest.TestCase):
if not self.topic:
self.topic = "%s-%s" % (self.id()[self.id().rindex(".") + 1:], random_string(10))
- self.client = KafkaClient('%s:%d' % (self.server.host, self.server.port))
+ if self.create_client:
+ self.client = KafkaClient('%s:%d' % (self.server.host, self.server.port))
+
ensure_topic_creation(self.client, self.topic)
+
self._messages = {}
def tearDown(self):
super(KafkaIntegrationTestCase, self).tearDown()
- self.client.close()
+ if self.create_client:
+ self.client.close()
def current_offset(self, topic, partition):
offsets, = self.client.send_offset_request([ OffsetRequest(topic, partition, -1, 1) ])
@@ -54,4 +59,13 @@ class KafkaIntegrationTestCase(unittest.TestCase):
return self._messages[s]
+class Timer(object):
+ def __enter__(self):
+ self.start = time.time()
+ return self
+
+ def __exit__(self, *args):
+ self.end = time.time()
+ self.interval = self.end - self.start
+
logging.basicConfig(level=logging.DEBUG)