Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
relativityspace-jsmith committed Feb 28, 2024
1 parent 26b163d commit 7bfc456
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions tests/basic_functionality_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def test_has_link_layer() -> None:
assert has_any_link, "Test failure; no AF_PACKET address of any kind found"


@pytest.mark.skipif(
platform.system() != "Windows", reason="Windows only"
) # type: ignore[misc]
@pytest.mark.skipif(platform.system() != "Windows", reason="Windows only") # type: ignore[misc]
def test_interface_display_formats_windows() -> None:
"""
Check that the InterfaceDisplay argument can be used to select between a UUID
Expand All @@ -57,23 +55,17 @@ def test_interface_display_formats_windows() -> None:
uuid_regex = r"{[-A-F0-9]+}"

# The machine readable interface should look like a UUID string
machine_readable_iface0 = netifaces.interfaces(
netifaces.InterfaceDisplay.MachineReadable
)[0]
machine_readable_iface0 = netifaces.interfaces(netifaces.InterfaceDisplay.MachineReadable)[0]
print(f"Machine readable name of interface 0 is: {machine_readable_iface0}")
assert re.fullmatch(uuid_regex, machine_readable_iface0) is not None

# The human readable interface should NOT look like a UUID
human_readable_iface0 = netifaces.interfaces(
netifaces.InterfaceDisplay.HumanReadable
)[0]
human_readable_iface0 = netifaces.interfaces(netifaces.InterfaceDisplay.HumanReadable)[0]
print(f"Human readable name of interface 0 is: {human_readable_iface0}")
assert re.fullmatch(uuid_regex, human_readable_iface0) is None


@pytest.mark.skipif(
platform.system() == "Windows", reason="Does not pass yet on Windows"
) # type: ignore[misc]
@pytest.mark.skipif(platform.system() == "Windows", reason="Does not pass yet on Windows") # type: ignore[misc]
def test_loopback_addr_is_returned() -> None:
"""
Test that the loopback address is returned in the lists of addresses
Expand All @@ -88,20 +80,14 @@ def test_loopback_addr_is_returned() -> None:

if netifaces.AF_INET in address_table:
for ipv4_settings in address_table[netifaces.InterfaceType.AF_INET]:
print(
f"Loopback test: Considering iface {interface} IPv4 address "
f"{ipv4_settings['addr']}"
)
print(f"Loopback test: Considering iface {interface} IPv4 address " f"{ipv4_settings['addr']}")
if ipv4_settings["addr"] == "127.0.0.1":
print("Loopback IPv4 found!")
loopback_ipv4_found = True

if netifaces.AF_INET6 in address_table:
for ipv6_settings in address_table[netifaces.InterfaceType.AF_INET6]:
print(
f"Loopback test: Considering iface {interface} IPv6 address "
f"{ipv6_settings['addr']}"
)
print(f"Loopback test: Considering iface {interface} IPv6 address " f"{ipv6_settings['addr']}")
if ipv6_settings["addr"] == "::1":
print("Loopback IPv6 found!")
loopback_ipv6_found = True
Expand Down

0 comments on commit 7bfc456

Please sign in to comment.