Skip to content

Commit 24008ff

Browse files
committed
Don't fail a test because there are no public IP addresses
When running the test suite on a machine without public IP addresses there is a list index out of range error: =================================== FAILURES =================================== _____________________________ test_disambiguate_ip _____________________________ def test_disambiguate_ip(): # garbage in, garbage out > public_ip = public_ips()[0] E IndexError: list index out of range ipyparallel/tests/test_util.py:11: IndexError This commit modifies the test by adding a check that the list is not empty before trying to access its first element.
1 parent e204e8c commit 24008ff

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ipyparallel/tests/test_util.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88

99
def test_disambiguate_ip():
1010
# garbage in, garbage out
11-
public_ip = public_ips()[0]
1211
assert util.disambiguate_ip_address('garbage') == 'garbage'
1312
assert util.disambiguate_ip_address('0.0.0.0', socket.gethostname()) == localhost()
1413
wontresolve = 'this.wontresolve.dns'
1514
with pytest.warns(
1615
RuntimeWarning, match=f"IPython could not determine IPs for {wontresolve}"
1716
):
1817
assert util.disambiguate_ip_address('0.0.0.0', wontresolve) == wontresolve
19-
assert util.disambiguate_ip_address('0.0.0.0', public_ip) == localhost()
18+
if public_ips():
19+
public_ip = public_ips()[0]
20+
assert util.disambiguate_ip_address('0.0.0.0', public_ip) == localhost()

0 commit comments

Comments
 (0)