[Network] Use NetworkAddress for dist_init_method and loopback fallbacks (#20657)

Co-authored-by: hnyls2002 <lsyincs@gmail.com>
This commit is contained in:
psaab
2026-03-16 19:59:49 -07:00
committed by GitHub
co-authored by hnyls2002
parent 71a54c1c42
commit 9f56b471aa
9 changed files with 79 additions and 44 deletions
@@ -179,23 +179,23 @@ class TestNetworkAddressParseErrors(unittest.TestCase):
NetworkAddress.parse(":8000")
class TestNetworkAddressFromParts(unittest.TestCase):
class TestNetworkAddressBracketStripping(unittest.TestCase):
def test_strip_brackets(self):
na = NetworkAddress.from_parts("[::1]", 8000)
na = NetworkAddress("[::1]", 8000)
self.assertEqual(na.host, "::1")
self.assertTrue(na.is_ipv6)
def test_no_brackets(self):
na = NetworkAddress.from_parts("::1", 8000)
na = NetworkAddress("::1", 8000)
self.assertEqual(na.host, "::1")
def test_ipv4_passthrough(self):
na = NetworkAddress.from_parts("127.0.0.1", 30000)
na = NetworkAddress("127.0.0.1", 30000)
self.assertEqual(na.host, "127.0.0.1")
self.assertFalse(na.is_ipv6)
def test_hostname_passthrough(self):
na = NetworkAddress.from_parts("myhost", 30000)
na = NetworkAddress("myhost", 30000)
self.assertEqual(na.host, "myhost")