summaryrefslogtreecommitdiff
path: root/test/fixtures.py
diff options
context:
space:
mode:
authorDana Powers <dana.powers@gmail.com>2016-02-15 20:20:56 -0800
committerDana Powers <dana.powers@gmail.com>2016-02-15 21:56:10 -0800
commit0d1ccc7485acf09b282d8cc7a06cfd94e690eddb (patch)
treed39b107f2e0c090cbfb3d48fe89ed592afb42107 /test/fixtures.py
parent251d4a97ced196503cbfbde2769a0394163a4325 (diff)
downloadkafka-python-0d1ccc7485acf09b282d8cc7a06cfd94e690eddb.tar.gz
Support setting kafka instance port explicitly in fixture
Diffstat (limited to 'test/fixtures.py')
-rw-r--r--test/fixtures.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/fixtures.py b/test/fixtures.py
index 2613a41..3892416 100644
--- a/test/fixtures.py
+++ b/test/fixtures.py
@@ -151,7 +151,8 @@ class ZookeeperFixture(Fixture):
class KafkaFixture(Fixture):
@classmethod
- def instance(cls, broker_id, zk_host, zk_port, zk_chroot=None, replicas=1, partitions=2):
+ def instance(cls, broker_id, zk_host, zk_port,
+ zk_chroot=None, port=None, replicas=1, partitions=2):
if zk_chroot is None:
zk_chroot = "kafka-python_" + str(uuid.uuid4()).replace("-", "_")
if "KAFKA_URI" in os.environ:
@@ -159,8 +160,11 @@ class KafkaFixture(Fixture):
(host, port) = (parse.hostname, parse.port)
fixture = ExternalService(host, port)
else:
- (host, port) = ("127.0.0.1", get_open_port())
- fixture = KafkaFixture(host, port, broker_id, zk_host, zk_port, zk_chroot, replicas, partitions)
+ if port is None:
+ port = get_open_port()
+ host = "127.0.0.1"
+ fixture = KafkaFixture(host, port, broker_id, zk_host, zk_port, zk_chroot,
+ replicas=replicas, partitions=partitions)
fixture.open()
return fixture