summaryrefslogtreecommitdiff
path: root/test/testutil.py
diff options
context:
space:
mode:
authorMark Roberts <wizzat@gmail.com>2014-04-22 23:14:23 -0700
committerMark Roberts <wizzat@gmail.com>2014-04-22 23:15:34 -0700
commitb6262e4c0bc8779b331987e05d133f2a046f70b2 (patch)
treec6ce7dafa5606ca1a1e941027499d6accedd535c /test/testutil.py
parentd35b8fd81fac594835e8ef2861a32b7dc08716ab (diff)
downloadkafka-python-b6262e4c0bc8779b331987e05d133f2a046f70b2.tar.gz
Update fixtures to eliminate extraneous logging on non-errors, split out mostly unrelated service.py, fix test in client_integration to use get_open_port, fix unintended import cascade in test_producer_integration
Diffstat (limited to 'test/testutil.py')
-rw-r--r--test/testutil.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/test/testutil.py b/test/testutil.py
index 2cf62eb..ccb3955 100644
--- a/test/testutil.py
+++ b/test/testutil.py
@@ -1,13 +1,24 @@
-import uuid
-import time
-import unittest
+import logging
import os
import random
+import socket
import string
-import logging
+import time
+import unittest
+import uuid
+
from kafka.common import OffsetRequest
from kafka import KafkaClient
+__all__ = [
+ 'random_string',
+ 'skip_integration',
+ 'ensure_topic_creation',
+ 'get_open_port',
+ 'KafkaIntegrationTestCase',
+ 'Timer',
+]
+
def random_string(l):
s = "".join(random.choice(string.letters) for i in xrange(l))
return s
@@ -25,6 +36,13 @@ def ensure_topic_creation(client, topic_name, timeout = 30):
client.load_metadata_for_topics(topic_name)
time.sleep(1)
+def get_open_port():
+ sock = socket.socket()
+ sock.bind(("", 0))
+ port = sock.getsockname()[1]
+ sock.close()
+ return port
+
class KafkaIntegrationTestCase(unittest.TestCase):
create_client = True
topic = None