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