def test_wait_joins_listening_thread_if_it_exists(self): """Tests wait() joins _listening_thread if it exists.""" process = Process('cmd') process._process = mock.Mock() mocked_thread = mock.Mock() process._listening_thread = mocked_thread process.wait(0) self.assertEqual(mocked_thread.join.called, True)
def test_wait_clears_listening_thread_if_it_exists(self): """Tests wait() joins _listening_thread if it exists. Threads can only be started once, so after wait has been called, we want to make sure we clear the listening thread. """ process = Process('cmd') process._process = mock.Mock() process._listening_thread = mock.Mock() process.wait(0) self.assertEqual(process._listening_thread, None)