Skip to content

Mock dns lookups in test_conn #1739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion test/test_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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()
Expand All @@ -25,7 +32,7 @@ def _socket(mocker):


@pytest.fixture
def conn(_socket):
def conn(_socket, dns_lookup):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me a moment to realize this fixture always provides a localhost... it'd be nice if there was a docstring explaining what this fixture is intended for and what it provides.

That's a more general comment about our fixtures though, as I've slowly waded through #1193 it's taken longer than it should have to follow the fixture paths because they aren't documented.

conn = BrokerConnection('localhost', 9092, socket.AF_INET)
return conn

Expand Down