| 1 |
"""Tests for hubs that are not asyncio-based.""" |
| 2 |
|
| 3 |
import pytest |
| 4 |
|
| 5 |
from eventlet.hubs import get_hub |
| 6 |
from eventlet.hubs.asyncio import Hub as AsyncioHub |
| 7 |
from eventlet.asyncio import spawn_for_awaitable |
| 8 |
|
| 9 |
if isinstance(get_hub(), AsyncioHub): |
| 10 |
pytest.skip("Only works on non-asyncio hub", allow_module_level=True) |
| 11 |
|
| 12 |
|
| 13 |
def test_spawn_from_coroutine_errors(): |
| 14 |
""" |
| 15 |
If ``spawn_for_awaitable()`` is called in a non-asyncio hub it will raise a |
| 16 |
``RuntimeError``. |
| 17 |
""" |
| 18 |
|
| 19 |
async def go(): |
| 20 |
return 13 |
| 21 |
|
| 22 |
with pytest.raises(RuntimeError): |
| 23 |
spawn_for_awaitable(go()) |