Move variable setup and update test

This commit is contained in:
jbouwh
2022-08-11 17:08:11 +00:00
parent 54f98ce447
commit a0d88bc601
2 changed files with 3 additions and 2 deletions

View File

@@ -100,6 +100,7 @@ async def async_setup_hass(
) -> core.HomeAssistant | None: ) -> core.HomeAssistant | None:
"""Set up Home Assistant.""" """Set up Home Assistant."""
hass = core.HomeAssistant() hass = core.HomeAssistant()
core._cv_hass.set(hass) # pylint: disable=protected-access
hass.config.config_dir = runtime_config.config_dir hass.config.config_dir = runtime_config.config_dir
async_enable_logging( async_enable_logging(
@@ -187,8 +188,6 @@ async def async_setup_hass(
if runtime_config.open_ui: if runtime_config.open_ui:
hass.add_job(open_hass_ui, hass) hass.add_job(open_hass_ui, hass)
core._cv_hass.set(hass) # pylint: disable=protected-access
return hass return hass

View File

@@ -501,6 +501,8 @@ async def test_setup_hass(
assert len(mock_ensure_config_exists.mock_calls) == 1 assert len(mock_ensure_config_exists.mock_calls) == 1
assert len(mock_process_ha_config_upgrade.mock_calls) == 1 assert len(mock_process_ha_config_upgrade.mock_calls) == 1
assert hass == core.async_get_hass()
async def test_setup_hass_takes_longer_than_log_slow_startup( async def test_setup_hass_takes_longer_than_log_slow_startup(
mock_enable_logging, mock_enable_logging,