1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-03 20:02:22 +01:00

Convert IPAddress to use Pythonmodule ipaddress (#8072)

This commit is contained in:
Jimmy Hedman
2025-01-12 20:12:38 +01:00
committed by GitHub
parent fe80750743
commit d69926485c
9 changed files with 65 additions and 75 deletions

View File

@@ -1,10 +1,8 @@
import pytest
from hypothesis import given
from hypothesis.strategies import ip_addresses
import pytest
from strategies import mac_addr_strings
from esphome import core, const
from esphome import const, core
class TestHexInt:
@@ -26,25 +24,6 @@ class TestHexInt:
assert actual == expected
class TestIPAddress:
@given(value=ip_addresses(v=4).map(str))
def test_init__valid(self, value):
core.IPAddress(*value.split("."))
@pytest.mark.parametrize("value", ("127.0.0", "localhost", ""))
def test_init__invalid(self, value):
with pytest.raises(ValueError, match="IPAddress must consist of 4 items"):
core.IPAddress(*value.split("."))
@given(value=ip_addresses(v=4).map(str))
def test_str(self, value):
target = core.IPAddress(*value.split("."))
actual = str(target)
assert actual == value
class TestMACAddress:
@given(value=mac_addr_strings())
def test_init__valid(self, value):