Skip to content

Commit a7268f0

Browse files
authored
Don't require network to inspect tests (#4433)
Previously the get_ipv6 function was called at import time in test_core.py This stopped any tests from running if a network adapter was not attached The results of this function were used only in one test, so we move this call within that test and skip if it fails
1 parent 467bbc2 commit a7268f0

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

distributed/tests/test_core.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
from distributed.utils_test import loop # noqa F401
4343

4444

45-
EXTERNAL_IP4 = get_ip()
46-
if has_ipv6():
47-
EXTERNAL_IP6 = get_ipv6()
48-
49-
5045
def echo(comm, x):
5146
return x
5247

@@ -194,6 +189,15 @@ async def test_server_listen():
194189
"""
195190
Test various Server.listen() arguments and their effect.
196191
"""
192+
import socket
193+
194+
try:
195+
EXTERNAL_IP4 = get_ip()
196+
if has_ipv6():
197+
EXTERNAL_IP6 = get_ipv6()
198+
except socket.gaierror:
199+
raise pytest.skip(reason="no network access")
200+
197201
from contextlib import asynccontextmanager
198202

199203
@asynccontextmanager

0 commit comments

Comments
 (0)