Use eventloop for scheduling (#37184)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
J. Nick Koston 2020-06-29 11:39:24 -05:00 committed by GitHub
parent 0f72008090
commit 89a9634d35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 366 additions and 272 deletions

View file

@ -3,6 +3,8 @@ from datetime import datetime, timedelta
import statistics
import unittest
import pytest
from homeassistant.components import recorder
from homeassistant.components.statistics.sensor import StatisticsSensor
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, STATE_UNKNOWN, TEMP_CELSIUS
@ -18,6 +20,12 @@ from tests.common import (
from tests.components.recorder.common import wait_recording_done
@pytest.fixture(autouse=True)
def mock_legacy_time(legacy_patchable_time):
"""Make time patchable for all the tests."""
yield
class TestStatisticsSensor(unittest.TestCase):
"""Test the Statistics sensor."""
@ -36,10 +44,7 @@ class TestStatisticsSensor(unittest.TestCase):
self.change = round(self.values[-1] - self.values[0], 2)
self.average_change = round(self.change / (len(self.values) - 1), 2)
self.change_rate = round(self.change / (60 * (self.count - 1)), 2)
def teardown_method(self, method):
"""Stop everything that was started."""
self.hass.stop()
self.addCleanup(self.hass.stop)
def test_binary_sensor_source(self):
"""Test if source is a sensor."""