μ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.
1# -*- coding: utf-8 -*-
2import pytest
3
4asyncio = pytest.importorskip("asyncio")
5m = pytest.importorskip("pybind11_tests.async_module")
6
7
8@pytest.fixture
10 loop = asyncio.new_event_loop()
11 yield loop
12 loop.close()
13
14
15async def get_await_result(x):
16 return await x
17
18
19def test_await(event_loop):
20 assert 5 == event_loop.run_until_complete(get_await_result(m.SupportsAsync()))
21
22
23def test_await_missing(event_loop):
24 with pytest.raises(TypeError):
25 event_loop.run_until_complete(get_await_result(m.DoesNotSupportAsync()))
def event_loop()
Definition: test_async.py:9
def test_await_missing(event_loop)
Definition: test_async.py:23
def get_await_result(x)
Definition: test_async.py:15
def test_await(event_loop)
Definition: test_async.py:19