Skip to content

Commit 9599215

Browse files
committed
Merge pull request #144 from frgtn/check_basestring_in_collect_hosts
Check against basestring instead of str in collect.hosts.
2 parents 32edabd + e08c718 commit 9599215

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

kafka/conn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def collect_hosts(hosts, randomize=True):
1919
randomize the returned list.
2020
"""
2121

22-
if isinstance(hosts, str):
22+
if isinstance(hosts, basestring):
2323
hosts = hosts.strip().split(',')
2424

2525
result = []

test/test_unit.py

+10
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,16 @@ def test_init_with_csv(self):
449449
[('kafka01', 9092), ('kafka02', 9092), ('kafka03', 9092)],
450450
client.hosts)
451451

452+
def test_init_with_unicode_csv(self):
453+
454+
with patch.object(KafkaClient, 'load_metadata_for_topics'):
455+
client = KafkaClient(
456+
hosts=u'kafka01:9092,kafka02:9092,kafka03:9092')
457+
458+
self.assertItemsEqual(
459+
[('kafka01', 9092), ('kafka02', 9092), ('kafka03', 9092)],
460+
client.hosts)
461+
452462
def test_send_broker_unaware_request_fail(self):
453463
'Tests that call fails when all hosts are unavailable'
454464

0 commit comments

Comments
 (0)