Skip to content

Commit ca910ca

Browse files
committed
test(vllm): cover hostname and IPv6 communicator addresses
1 parent 25a5281 commit ca910ca

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

tests/test_vllm_client_server.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import os
1616
import subprocess
17+
from unittest.mock import patch
1718
from types import SimpleNamespace
1819

1920
import pytest
@@ -45,8 +46,13 @@
4546

4647
class TestVLLMClientAddressing(TrlTestCase):
4748
def test_communicator_host_strips_ipv6_brackets(self):
48-
assert _normalize_communicator_host("[2001:db8::1]") == "2001:db8::1"
49-
assert _normalize_communicator_host("2001:db8::1") == "2001:db8::1"
49+
assert _resolve_communicator_host("[2001:db8::1]") == "2001:db8::1"
50+
assert _resolve_communicator_host("2001:db8::1") == "2001:db8::1"
51+
52+
@patch("trl.generation.vllm_client.socket.gethostbyname", return_value="127.0.0.1")
53+
def test_communicator_host_resolves_hostname(self, gethostbyname):
54+
assert _resolve_communicator_host("localhost") == "127.0.0.1"
55+
gethostbyname.assert_called_once_with("localhost")
5056

5157
def test_http_host_brackets_only_ipv6_literals(self):
5258
assert _format_http_host("[2001:db8::1]") == "[2001:db8::1]"

0 commit comments

Comments
 (0)