Optimize event matcher (#9798)

* Optimize event matcher

* Tweak order of checks

* Add a benchmark for time_changed helper

* Add state change benchmark

* fix lint
This commit is contained in:
Paulus Schoutsen 2017-10-10 13:26:03 -07:00 committed by Pascal Vizeli
parent a97e7bb22d
commit 8f06b35dfc
3 changed files with 104 additions and 43 deletions

View file

@ -5,6 +5,7 @@ import unittest
from datetime import datetime, timedelta
from astral import Astral
import pytest
from homeassistant.setup import setup_component
import homeassistant.core as ha
@ -634,8 +635,9 @@ class TestEventHelpers(unittest.TestCase):
"""Test periodic tasks with wrong input."""
specific_runs = []
track_utc_time_change(
self.hass, lambda x: specific_runs.append(1), year='/two')
with pytest.raises(ValueError):
track_utc_time_change(
self.hass, lambda x: specific_runs.append(1), year='/two')
self._send_time_changed(datetime(2014, 5, 2, 0, 0, 0))
self.hass.block_till_done()