Example #1
0
    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)
Example #2
0
    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)
Example #3
0
    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
Example #4
0
    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