test_async.py
Go to the documentation of this file.
1 import pytest
2 
3 asyncio = pytest.importorskip("asyncio")
4 m = pytest.importorskip("pybind11_tests.async_module")
5 
6 
7 @pytest.fixture()
8 def event_loop():
9  loop = asyncio.new_event_loop()
10  yield loop
11  loop.close()
12 
13 
14 async def get_await_result(x):
15  return await x
16 
17 
18 def test_await(event_loop):
19  assert event_loop.run_until_complete(get_await_result(m.SupportsAsync())) == 5
20 
21 
22 def test_await_missing(event_loop):
23  with pytest.raises(TypeError):
24  event_loop.run_until_complete(get_await_result(m.DoesNotSupportAsync()))
test_async.test_await
def test_await(event_loop)
Definition: test_async.py:18
test_async.test_await_missing
def test_await_missing(event_loop)
Definition: test_async.py:22
test_async.event_loop
def event_loop()
Definition: test_async.py:8
test_async.get_await_result
def get_await_result(x)
Definition: test_async.py:14


gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:05:27