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