From de066c7fc08239f9b53289247fc63964dab2a188 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:22:10 +0100 Subject: [PATCH] Reset log level in script tests (#109881) --- tests/scripts/test_auth.py | 10 ++++++++++ tests/scripts/test_check_config.py | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/scripts/test_auth.py b/tests/scripts/test_auth.py index 82a8a408c53ea7..3d9f26d1204782 100644 --- a/tests/scripts/test_auth.py +++ b/tests/scripts/test_auth.py @@ -1,4 +1,5 @@ """Test the auth script to manage local users.""" +import logging from typing import Any from unittest.mock import Mock, patch @@ -11,6 +12,15 @@ from tests.common import register_auth_provider +@pytest.fixture(autouse=True) +def reset_log_level(): + """Reset log level after each test case.""" + logger = logging.getLogger("homeassistant.core") + orig_level = logger.level + yield + logger.setLevel(orig_level) + + @pytest.fixture def provider(hass): """Home Assistant auth provider.""" diff --git a/tests/scripts/test_check_config.py b/tests/scripts/test_check_config.py index 425ad561f509e6..9e2f6708c9901c 100644 --- a/tests/scripts/test_check_config.py +++ b/tests/scripts/test_check_config.py @@ -1,4 +1,5 @@ """Test check_config script.""" +import logging from unittest.mock import patch import pytest @@ -22,6 +23,15 @@ BAD_CORE_CONFIG = "homeassistant:\n unit_system: bad\n\n\n" +@pytest.fixture(autouse=True) +def reset_log_level(): + """Reset log level after each test case.""" + logger = logging.getLogger("homeassistant.loader") + orig_level = logger.level + yield + logger.setLevel(orig_level) + + @pytest.fixture(autouse=True) async def apply_stop_hass(stop_hass: None) -> None: """Make sure all hass are stopped."""