From 86f1de056ebfd4996bf06ee1e50fe7b8e1a4c1d9 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 1 Jul 2025 08:02:31 +0000 Subject: [PATCH] Adjust --- homeassistant/helpers/service_info/dhcp.py | 5 +---- tests/conftest.py | 24 +++++++++++----------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/homeassistant/helpers/service_info/dhcp.py b/homeassistant/helpers/service_info/dhcp.py index 94441749c65..1d8c336728f 100644 --- a/homeassistant/helpers/service_info/dhcp.py +++ b/homeassistant/helpers/service_info/dhcp.py @@ -20,7 +20,4 @@ class DhcpServiceInfo(BaseServiceInfo): """ def __post_init__(self) -> None: - """Post-init processing.""" - # Ensure macaddress is always a lowercase string without colons - if self.macaddress != self.macaddress.lower().replace(":", ""): - raise ValueError("macaddress is not correctly formatted") + """Post init checks.""" diff --git a/tests/conftest.py b/tests/conftest.py index 643b37d9b32..4fc3996bc7c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -156,6 +156,18 @@ asyncio.set_event_loop_policy(runner.HassEventLoopPolicy(False)) asyncio.set_event_loop_policy = lambda policy: None +def _dhcp_service_info_post_init(self: DhcpServiceInfo) -> None: + """Post-init processing for DhcpServiceInfo. + + Ensure that the macaddress is always in lowercase and without colons to match DHCP service. + """ + if self.macaddress != self.macaddress.lower().replace(":", ""): + raise ValueError("macaddress is not correctly formatted") + + +DhcpServiceInfo.__post_init__ = _dhcp_service_info_post_init + + def pytest_addoption(parser: pytest.Parser) -> None: """Register custom pytest options.""" parser.addoption("--dburl", action="store", default="sqlite://") @@ -2079,15 +2091,3 @@ def disable_block_async_io() -> Generator[None]: blocking_call.object, blocking_call.function, blocking_call.original_func ) calls.clear() - - -def _dhcp_service_info_post_init(self: DhcpServiceInfo) -> None: - """Post-init processing for DhcpServiceInfo. - - Ensure that the macaddress is always in lowercase and without colons to match DHCP service. - """ - if self.macaddress != self.macaddress.lower().replace(":", ""): - raise ValueError("macaddress is not correctly formatted") - - -DhcpServiceInfo.__post_init__ = _dhcp_service_info_post_init