From 469aad5fc8eb8efcb310205843b31f271787fd10 Mon Sep 17 00:00:00 2001 From: Jan Losinski Date: Sun, 8 Jan 2017 14:23:01 +0100 Subject: [PATCH] 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 * Update test_pilight.py --- tests/components/test_pilight.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/components/test_pilight.py b/tests/components/test_pilight.py index 0fe68b4fbe5..036beb0c139 100644 --- a/tests/components/test_pilight.py +++ b/tests/components/test_pilight.py @@ -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 = []