Simplify time zone setting in tests (#68330)
* Simplify timezone setting in tests * Fix typo * Adjust caldav tests * Adjust input_datetime tests * Adjust time_date tests * Adjust tod tests * Adjust helper tests * Adjust recorder tests * Adjust risco tests * Adjust aemet tests * Adjust flux tests * Adjust forecast_solar tests * Revert unnecessary change in forecast_solar test * Adjust climacell tests * Adjust google tests * Adjust sensor tests * Adjust sonarr tests * Adjust template tests * Adjust zodiac tests Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
dbeec1f7da
commit
cf4033b1bc
33 changed files with 256 additions and 320 deletions
|
@ -29,7 +29,7 @@ from homeassistant.components.websocket_api.http import URL
|
|||
from homeassistant.const import ATTR_NOW, EVENT_TIME_CHANGED, HASSIO_USER_NAME
|
||||
from homeassistant.helpers import config_entry_oauth2_flow, event
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import location
|
||||
from homeassistant.util import dt as dt_util, location
|
||||
|
||||
from tests.ignore_uncaught_exceptions import IGNORE_UNCAUGHT_EXCEPTIONS
|
||||
|
||||
|
@ -249,6 +249,8 @@ def load_registries():
|
|||
def hass(loop, load_registries, hass_storage, request):
|
||||
"""Fixture to provide a test instance of Home Assistant."""
|
||||
|
||||
orig_tz = dt_util.DEFAULT_TIME_ZONE
|
||||
|
||||
def exc_handle(loop, context):
|
||||
"""Handle exceptions by rethrowing them, which will fail the test."""
|
||||
# Most of these contexts will contain an exception, but not all.
|
||||
|
@ -273,6 +275,10 @@ def hass(loop, load_registries, hass_storage, request):
|
|||
yield hass
|
||||
|
||||
loop.run_until_complete(hass.async_stop(force=True))
|
||||
|
||||
# Restore timezone, it is set when creating the hass object
|
||||
dt_util.DEFAULT_TIME_ZONE = orig_tz
|
||||
|
||||
for ex in exceptions:
|
||||
if (
|
||||
request.module.__name__,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue