Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:51

0001 import pytest
0002 
0003 asyncio = pytest.importorskip("asyncio")
0004 m = pytest.importorskip("pybind11_tests.async_module")
0005 
0006 
0007 @pytest.fixture
0008 def event_loop():
0009     loop = asyncio.new_event_loop()
0010     yield loop
0011     loop.close()
0012 
0013 
0014 async def get_await_result(x):
0015     return await x
0016 
0017 
0018 def test_await(event_loop):
0019     assert 5 == event_loop.run_until_complete(get_await_result(m.SupportsAsync()))
0020 
0021 
0022 def test_await_missing(event_loop):
0023     with pytest.raises(TypeError):
0024         event_loop.run_until_complete(get_await_result(m.DoesNotSupportAsync()))