def test_wait_joins_redirection_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._redirection_thread = mocked_thread process.wait(0) self.assertEqual(mocked_thread.join.called, True)
def test_wait_clears_redirection_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._redirection_thread = mock.Mock() process.wait(0) self.assertEqual(process._redirection_thread, None)