diff options
author | Marc Labbé <mrlabbe@gmail.com> | 2014-03-17 22:40:37 -0400 |
---|---|---|
committer | Marc Labbé <mrlabbe@gmail.com> | 2014-03-17 22:40:37 -0400 |
commit | 9599215bf28b65a29908b8644dcaa6f3614a425d (patch) | |
tree | f4cfc1daf3ba755d03be960a676dfdff5988318c | |
parent | 32edabdaaff6746e4926cc897b4bba917a80cb54 (diff) | |
parent | e08c718ca65c04d012f32e0053e58e851b04f40e (diff) | |
download | kafka-python-9599215bf28b65a29908b8644dcaa6f3614a425d.tar.gz |
Merge pull request #144 from frgtn/check_basestring_in_collect_hosts
Check against basestring instead of str in collect.hosts.
-rw-r--r-- | kafka/conn.py | 2 | ||||
-rw-r--r-- | test/test_unit.py | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/kafka/conn.py b/kafka/conn.py index 7266ae8..7538e8d 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 aec0a2c..081acc7 100644 --- a/test/test_unit.py +++ b/test/test_unit.py @@ -449,6 +449,16 @@ class TestKafkaClient(unittest.TestCase): [('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' |