diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/python/prompt-toolkit/py3/tests/test_async_generator.py | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/tests/test_async_generator.py')
-rw-r--r-- | contrib/python/prompt-toolkit/py3/tests/test_async_generator.py | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/contrib/python/prompt-toolkit/py3/tests/test_async_generator.py b/contrib/python/prompt-toolkit/py3/tests/test_async_generator.py index 4970d0c6383..fd2c109c955 100644 --- a/contrib/python/prompt-toolkit/py3/tests/test_async_generator.py +++ b/contrib/python/prompt-toolkit/py3/tests/test_async_generator.py @@ -1,24 +1,24 @@ -from prompt_toolkit.eventloop import generator_to_async_generator, get_event_loop - - -def _sync_generator(): - yield 1 - yield 10 - - -def test_generator_to_async_generator(): - """ - Test conversion of sync to asycn 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. - get_event_loop().run_until_complete(consume_async_generator()) - assert items == [1, 10] +from prompt_toolkit.eventloop import generator_to_async_generator, get_event_loop + + +def _sync_generator(): + yield 1 + yield 10 + + +def test_generator_to_async_generator(): + """ + Test conversion of sync to asycn 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. + get_event_loop().run_until_complete(consume_async_generator()) + assert items == [1, 10] |