Skip to content

Commit 39dd8c2

Browse files
dpkpjeffwidman
authored andcommitted
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.
1 parent 302b30c commit 39dd8c2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/test_conn.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
import kafka.errors as Errors
1717

1818

19+
@pytest.fixture
20+
def dns_lookup(mocker):
21+
return mocker.patch('kafka.conn.dns_lookup',
22+
return_value=[(socket.AF_INET,
23+
None, None, None,
24+
('localhost', 9092))])
25+
1926
@pytest.fixture
2027
def _socket(mocker):
2128
socket = mocker.MagicMock()
@@ -25,7 +32,7 @@ def _socket(mocker):
2532

2633

2734
@pytest.fixture
28-
def conn(_socket):
35+
def conn(_socket, dns_lookup):
2936
conn = BrokerConnection('localhost', 9092, socket.AF_INET)
3037
return conn
3138

0 commit comments

Comments
 (0)