summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Powers <dana.powers@gmail.com>2019-03-13 21:43:29 -0700
committerJeff Widman <jeff@jeffwidman.com>2019-03-13 21:43:29 -0700
commit39dd8c28da133fcc5005db3db127d687882dfe99 (patch)
tree5dc6c84de6fdf2a08f0ce13da9c6322e4b587031
parent302b30c7c9f911ce8ec948926021d3fdf16cbedc (diff)
downloadkafka-python-39dd8c28da133fcc5005db3db127d687882dfe99.tar.gz
Mock dns lookups in test_conn (#1739)
Small change to avoid doing dns resolution when running local connection tests. This fixture always returns a broker on localhost:9092, so DNS lookups don't make sense here.
-rw-r--r--test/test_conn.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/test_conn.py b/test/test_conn.py
index 953c112..66b8a0c 100644
--- a/test/test_conn.py
+++ b/test/test_conn.py
@@ -17,6 +17,13 @@ import kafka.errors as Errors
@pytest.fixture
+def dns_lookup(mocker):
+ return mocker.patch('kafka.conn.dns_lookup',
+ return_value=[(socket.AF_INET,
+ None, None, None,
+ ('localhost', 9092))])
+
+@pytest.fixture
def _socket(mocker):
socket = mocker.MagicMock()
socket.connect_ex.return_value = 0
@@ -25,7 +32,7 @@ def _socket(mocker):
@pytest.fixture
-def conn(_socket):
+def conn(_socket, dns_lookup):
conn = BrokerConnection('localhost', 9092, socket.AF_INET)
return conn