Enable debug mode if asyncio debug is on at startup (#116084)

pull/116047/merge
J. Nick Koston 2024-04-24 12:55:09 +02:00 committed by GitHub
parent df12789e08
commit d17e9bfc99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 1 deletions

View File

@ -253,8 +253,9 @@ async def async_setup_hass(
runtime_config.log_no_color,
)
if runtime_config.debug:
if runtime_config.debug or hass.loop.get_debug():
hass.config.debug = True
hass.config.safe_mode = runtime_config.safe_mode
hass.config.skip_pip = runtime_config.skip_pip
hass.config.skip_pip_packages = runtime_config.skip_pip_packages
@ -318,6 +319,7 @@ async def async_setup_hass(
hass = core.HomeAssistant(old_config.config_dir)
if old_logging:
hass.data[DATA_LOGGING] = old_logging
hass.config.debug = old_config.debug
hass.config.skip_pip = old_config.skip_pip
hass.config.skip_pip_packages = old_config.skip_pip_packages
hass.config.internal_url = old_config.internal_url

View File

@ -122,6 +122,38 @@ async def test_config_does_not_turn_off_debug(hass: HomeAssistant) -> None:
assert hass.config.debug is True
@pytest.mark.parametrize("hass_config", [{"frontend": {}}])
async def test_asyncio_debug_on_turns_hass_debug_on(
mock_hass_config: None,
mock_enable_logging: Mock,
mock_is_virtual_env: Mock,
mock_mount_local_lib_path: AsyncMock,
mock_ensure_config_exists: AsyncMock,
mock_process_ha_config_upgrade: Mock,
) -> None:
"""Test that asyncio debug turns on hass debug."""
asyncio.get_running_loop().set_debug(True)
verbose = Mock()
log_rotate_days = Mock()
log_file = Mock()
log_no_color = Mock()
hass = await bootstrap.async_setup_hass(
runner.RuntimeConfig(
config_dir=get_test_config_dir(),
verbose=verbose,
log_rotate_days=log_rotate_days,
log_file=log_file,
log_no_color=log_no_color,
skip_pip=True,
recovery_mode=False,
),
)
assert hass.config.debug is True
@pytest.mark.parametrize("load_registries", [False])
async def test_preload_translations(hass: HomeAssistant) -> None:
"""Test translations are preloaded for all frontend deps and base platforms."""