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


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:39:26