def test_wait_timeout(self): test_future = Future("TestData") def test_method(*args, **kwargs): time.sleep(2) return True test_future.freeze(test_method) self.future_thread = threading.Thread(target=test_future.thaw) self.future_thread.start() with pytest.raises(TimeoutError): test_future.wait(1)
def test_wait(self): test_future = Future("TestData") def test_method(*args, **kwargs): time.sleep(2) return True test_future.freeze(test_method) self.future_thread = threading.Thread(target=test_future.thaw) self.future_thread.start() expected = True actual = test_future.wait() assert expected == actual