def test_get_loop(self): """ Test the get_loop method. """ from supvisors.mainloop import SupvisorsMainLoop main_loop = SupvisorsMainLoop(self.supvisors) self.assertFalse(main_loop.get_loop()) main_loop.loop = True self.assertTrue(main_loop.get_loop())
def test_stop(self): """ Test the stopping of the main loop thread. """ from supvisors.mainloop import SupvisorsMainLoop main_loop = SupvisorsMainLoop(self.supvisors) # try to stop main loop before it is started with self.assertRaises(RuntimeError): main_loop.stop() # stop main loop after it is started main_loop.loop = True with patch.object(main_loop, 'join') as mocked_join: main_loop.stop() self.assertFalse(main_loop.loop) self.assertEqual(1, mocked_join.call_count)