| 1 |
# ----------------------------------------------------------------------------- |
| 2 |
# Copyright (c) The Jupyter Development Team |
| 3 |
# |
| 4 |
# Distributed under the terms of the BSD License. The full license is in |
| 5 |
# the file LICENSE, distributed as part of this software. |
| 6 |
# ----------------------------------------------------------------------------- |
| 7 |
import sys |
| 8 |
|
| 9 |
from jupyter_client import localinterfaces |
| 10 |
|
| 11 |
|
| 12 |
def test_load_ips(): |
| 13 |
# Override the machinery that skips it if it was called before |
| 14 |
localinterfaces._load_ips.called = False # type:ignore[attr-defined] |
| 15 |
|
| 16 |
# Just check this doesn't error |
| 17 |
localinterfaces._load_ips(suppress_exceptions=False) |
| 18 |
|
| 19 |
localinterfaces.is_local_ip("8.8.8.8") |
| 20 |
localinterfaces.is_public_ip("127.0.0.1") |
| 21 |
ips = localinterfaces.local_ips() |
| 22 |
assert "127.0.0.1" in ips |
| 23 |
|
| 24 |
localinterfaces._load_ips_gethostbyname() |
| 25 |
localinterfaces._load_ips_dumb() |
| 26 |
|
| 27 |
if sys.platform == "linux": |
| 28 |
localinterfaces._load_ips_ip() |
| 29 |
localinterfaces._load_ips_ifconfig() |