diff --git a/tests/component_tests/conftest.py b/tests/component_tests/conftest.py index 3730978ec3..4f0b786cc2 100644 --- a/tests/component_tests/conftest.py +++ b/tests/component_tests/conftest.py @@ -57,6 +57,14 @@ def reset_core() -> Generator[None]: CORE.reset() +@pytest.fixture(autouse=True) +def reset_full_config() -> Generator[None]: + """Give each test a clean final-validate config and restore it after.""" + token = final_validate.full_config.set({}) + yield + final_validate.full_config.reset(token) + + @pytest.fixture def set_core_config() -> Generator[SetCoreConfigCallable]: """Fixture to set up the core configuration for tests.""" diff --git a/tests/component_tests/ethernet/test_ethernet.py b/tests/component_tests/ethernet/test_ethernet.py index 9308d0b099..522357f972 100644 --- a/tests/component_tests/ethernet/test_ethernet.py +++ b/tests/component_tests/ethernet/test_ethernet.py @@ -27,14 +27,6 @@ _CH390_CONFIG = { } -@pytest.fixture(autouse=True) -def _reset_full_config(): - """Reset fv.full_config so each test starts with a clean slate.""" - token = fv.full_config.set({}) - yield - fv.full_config.reset(token) - - def test_rejects_wifi_and_ethernet_without_priority() -> None: """Wi-Fi + ethernet without a network: priority: list must be rejected.""" fv.full_config.set({"wifi": {}, "ethernet": {}}) diff --git a/tests/component_tests/ethernet/test_spi_id.py b/tests/component_tests/ethernet/test_spi_id.py index cf87045751..e6dc9249e6 100644 --- a/tests/component_tests/ethernet/test_spi_id.py +++ b/tests/component_tests/ethernet/test_spi_id.py @@ -49,14 +49,6 @@ _W5500_SPI_ID_CONFIG = { } -@pytest.fixture(autouse=True) -def _reset_full_config(): - """Reset fv.full_config so each test starts with a clean slate.""" - token = fv.full_config.set({}) - yield - fv.full_config.reset(token) - - def _set_esp32_s3(set_core_config: SetCoreConfigCallable) -> None: set_core_config( PlatformFramework.ESP32_IDF, diff --git a/tests/component_tests/network/test_priority.py b/tests/component_tests/network/test_priority.py index 017f0711a3..041b358dda 100644 --- a/tests/component_tests/network/test_priority.py +++ b/tests/component_tests/network/test_priority.py @@ -24,11 +24,9 @@ from tests.component_tests.types import SetCoreConfigCallable @pytest.fixture(autouse=True) def _clear_core_data(): - """Wipe CORE.data and reset fv.full_config so each test starts clean.""" + """Wipe CORE.data so each test starts clean.""" CORE.data.clear() - token = fv.full_config.set({}) yield - fv.full_config.reset(token) CORE.data.clear()