/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
contrib/python/prompt-toolkit/py3/tests/test_async_generator.py
28 строк
658 B
robot-contrib
Update contrib/python/prompt-toolkit/py3 to 3.0.43
27 дек 2023, 10:40
27 дек 2023, 10:40
a55ebca
Код
Авторство
О чём код?
from __future__ import annotations from asyncio import run from prompt_toolkit.eventloop import generator_to_async_generator def _sync_generator(): yield 1 yield 10 def test_generator_to_async_generator(): """ Test conversion of sync to async generator. This should run the synchronous parts in a background thread. """ async_gen = generator_to_async_generator(_sync_generator) items = [] async def consume_async_generator(): async for item in async_gen: items.append(item) # Run the event loop until all items are collected. run(consume_async_generator()) assert items == [1, 10]