From e08c718ca65c04d012f32e0053e58e851b04f40e Mon Sep 17 00:00:00 2001 From: Saulius Zemaitaitis Date: Mon, 17 Mar 2014 17:06:48 +0200 Subject: [PATCH] Check against basestring instead of str in collect.hosts. --- kafka/conn.py | 2 +- test/test_unit.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/kafka/conn.py b/kafka/conn.py index 7266ae840..7538e8d3b 100644 --- a/kafka/conn.py +++ b/kafka/conn.py @@ -19,7 +19,7 @@ def collect_hosts(hosts, randomize=True): randomize the returned list. """ - if isinstance(hosts, str): + if isinstance(hosts, basestring): hosts = hosts.strip().split(',') result = [] diff --git a/test/test_unit.py b/test/test_unit.py index aec0a2c2f..081acc793 100644 --- a/test/test_unit.py +++ b/test/test_unit.py @@ -449,6 +449,16 @@ def test_init_with_csv(self): [('kafka01', 9092), ('kafka02', 9092), ('kafka03', 9092)], client.hosts) + def test_init_with_unicode_csv(self): + + with patch.object(KafkaClient, 'load_metadata_for_topics'): + client = KafkaClient( + hosts=u'kafka01:9092,kafka02:9092,kafka03:9092') + + self.assertItemsEqual( + [('kafka01', 9092), ('kafka02', 9092), ('kafka03', 9092)], + client.hosts) + def test_send_broker_unaware_request_fail(self): 'Tests that call fails when all hosts are unavailable'