μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
test_async.py
Go to the documentation of this file.
1import pytest
2
3asyncio = pytest.importorskip("asyncio")
4m = pytest.importorskip("pybind11_tests.async_module")
5
6
7@pytest.fixture
8def event_loop():
9 loop = asyncio.new_event_loop()
10 yield loop
11 loop.close()
12
13
14async def get_await_result(x):
15 return await x
16
17
18def test_await(event_loop):
19 assert 5 == event_loop.run_until_complete(get_await_result(m.SupportsAsync()))
20
21
22def test_await_missing(event_loop):
23 with pytest.raises(TypeError):
24 event_loop.run_until_complete(get_await_result(m.DoesNotSupportAsync()))