File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414
1515import os
1616import subprocess
17+ from unittest .mock import patch
1718from types import SimpleNamespace
1819
1920import pytest
4546
4647class 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]"
You can’t perform that action at this time.
0 commit comments