mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-27 07:32:02 +00:00
4d9024ec71
* tests: refactor and cleanup * refactor: more consistent * tests: vendor six * tests: more xfails, nicer system * tests: simplify to info * tests: suggestions from @YannickJadoul and @bstaletic * tests: restore some pypy tests that now pass * tests: rename info to env * tests: strict False/True * tests: drop explicit strict=True again * tests: reduce minimum PyTest to 3.1
26 lines
558 B
Python
26 lines
558 B
Python
# -*- coding: utf-8 -*-
|
|
import pytest
|
|
|
|
asyncio = pytest.importorskip("asyncio")
|
|
m = pytest.importorskip("pybind11_tests.async_module")
|
|
|
|
|
|
@pytest.fixture
|
|
def event_loop():
|
|
loop = asyncio.new_event_loop()
|
|
yield loop
|
|
loop.close()
|
|
|
|
|
|
async def get_await_result(x):
|
|
return await x
|
|
|
|
|
|
def test_await(event_loop):
|
|
assert 5 == event_loop.run_until_complete(get_await_result(m.SupportsAsync()))
|
|
|
|
|
|
def test_await_missing(event_loop):
|
|
with pytest.raises(TypeError):
|
|
event_loop.run_until_complete(get_await_result(m.DoesNotSupportAsync()))
|