mirror of
https://github.com/thelsing/knx.git
synced 2026-02-23 13:50:35 +01:00
Merge commit 'f34e604d3b4bee5339ec4e9c9f36619b17f52e32' as 'examples/knxPython/pybind11'
This commit is contained in:
25
examples/knxPython/pybind11/tests/test_async.py
Normal file
25
examples/knxPython/pybind11/tests/test_async.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- 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()))
|
||||
Reference in New Issue
Block a user