mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
tests: Add separate unit test for AsyncFuture.wait() with timeout
Since it's using a different implementation than the no-timeout version now
This commit is contained in:
parent
6bc22d1822
commit
5695d1a719
@ -88,6 +88,30 @@ def test_future_wait():
|
|||||||
assert fut.result() is None
|
assert fut.result() is None
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(not core.Thread.is_threading_supported(),
|
||||||
|
reason="Threading support disabled")
|
||||||
|
def test_future_wait_timeout():
|
||||||
|
threading = pytest.importorskip("direct.stdpy.threading")
|
||||||
|
|
||||||
|
fut = core.AsyncFuture()
|
||||||
|
|
||||||
|
# Launch a thread to set the result value.
|
||||||
|
def thread_main():
|
||||||
|
time.sleep(0.001)
|
||||||
|
fut.set_result(None)
|
||||||
|
|
||||||
|
thread = threading.Thread(target=thread_main)
|
||||||
|
|
||||||
|
assert not fut.done()
|
||||||
|
thread.start()
|
||||||
|
|
||||||
|
assert fut.result(1.0) is None
|
||||||
|
|
||||||
|
assert fut.done()
|
||||||
|
assert not fut.cancelled()
|
||||||
|
assert fut.result() is None
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not core.Thread.is_threading_supported(),
|
@pytest.mark.skipif(not core.Thread.is_threading_supported(),
|
||||||
reason="Threading support disabled")
|
reason="Threading support disabled")
|
||||||
def test_future_wait_cancel():
|
def test_future_wait_cancel():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user