mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add teardown method to pilight tests (#5195)
* Add teardown method to pilight tests This is necessary to stop the HomeAssistant instance that was started in the setUp method. Without this there happen random test failures. This is necessary to stabilize the tests for PR #5045. Signed-off-by: Jan Losinski <losinski@wh2.tu-dresden.de> * Update test_pilight.py
This commit is contained in:
committed by
Paulus Schoutsen
parent
a65388e778
commit
469aad5fc8
@@ -69,6 +69,12 @@ class TestPilight(unittest.TestCase):
|
||||
def setUp(self): # pylint: disable=invalid-name
|
||||
"""Setup things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
self.skip_teardown_stop = False
|
||||
|
||||
def tearDown(self):
|
||||
"""Stop everything that was started."""
|
||||
if not self.skip_teardown_stop:
|
||||
self.hass.stop()
|
||||
|
||||
@patch('homeassistant.components.pilight._LOGGER.error')
|
||||
def test_connection_failed_error(self, mock_error):
|
||||
@@ -208,6 +214,7 @@ class TestPilight(unittest.TestCase):
|
||||
'PilightDaemonSim start' in str(error_log_call))
|
||||
|
||||
# Test stop
|
||||
self.skip_teardown_stop = True
|
||||
self.hass.stop()
|
||||
error_log_call = mock_pilight_error.call_args_list[-1]
|
||||
self.assertTrue(
|
||||
@@ -344,6 +351,10 @@ class TestPilightCallrateThrottler(unittest.TestCase):
|
||||
"""Setup things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
|
||||
def tearDown(self):
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
def test_call_rate_delay_throttle_disabled(self):
|
||||
"""Test that the limiter is a noop if no delay set."""
|
||||
runs = []
|
||||
|
||||
Reference in New Issue
Block a user