1import asyncio 2import pytest 3from pybind11_tests import async_module as m 4 5 6@pytest.fixture 7def event_loop(): 8 loop = asyncio.new_event_loop() 9 yield loop 10 loop.close() 11 12 13async def get_await_result(x): 14 return await x 15 16 17def test_await(event_loop): 18 assert 5 == event_loop.run_until_complete(get_await_result(m.SupportsAsync())) 19 20 21def test_await_missing(event_loop): 22 with pytest.raises(TypeError): 23 event_loop.run_until_complete(get_await_result(m.DoesNotSupportAsync())) 24