1# -*- coding: utf-8 -*- 2import pytest 3 4asyncio = pytest.importorskip("asyncio") 5m = pytest.importorskip("pybind11_tests.async_module") 6 7 8@pytest.fixture 9def event_loop(): 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())) 26