-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
118 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,63 @@ | ||
# import pytest | ||
# import asyncio | ||
# import logging | ||
import asyncio | ||
import logging | ||
|
||
# from aioreactive.testing import VirtualTimeEventLoop | ||
# from aioreactive.core import AsyncObservable, run, subscribe, AsyncStream, AsyncAnonymousObserver, AsyncIteratorObserver | ||
# from aioreactive.operators.pipe import pipe | ||
# from aioreactive.operators import op, from_async_iterable | ||
# from aioreactive.operators.to_async_iterable import to_async_iterable | ||
import aioreactive as rx | ||
import pytest | ||
from aioreactive.testing import VirtualTimeEventLoop | ||
|
||
# log = logging.getLogger(__name__) | ||
# logging.basicConfig(level=logging.DEBUG) | ||
log = logging.getLogger(__name__) | ||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
|
||
# @pytest.yield_fixture() | ||
# def event_loop() -> None: | ||
# loop = VirtualTimeEventLoop() | ||
# yield loop | ||
# loop.close() | ||
@pytest.yield_fixture() # type: ignore | ||
def event_loop(): | ||
loop = VirtualTimeEventLoop() | ||
yield loop | ||
loop.close() | ||
|
||
|
||
# @pytest.mark.asyncio | ||
# async def test_async_iteration() -> None: | ||
# xs = AsyncObservable.from_iterable([1, 2, 3]) | ||
# result = [] | ||
@pytest.mark.asyncio | ||
async def test_async_iteration() -> None: | ||
xs = rx.from_iterable([1, 2, 3]) | ||
result = [] | ||
|
||
# async for x in to_async_iterable(xs): | ||
# result.append(x) | ||
async for x in rx.to_async_iterable(xs): | ||
result.append(x) | ||
|
||
# assert result == [1, 2, 3] | ||
assert result == [1, 2, 3] | ||
|
||
|
||
# @pytest.mark.asyncio | ||
# async def test_async_comprehension() -> None: | ||
# xs = AsyncObservable.from_iterable([1, 2, 3]) | ||
@pytest.mark.asyncio | ||
async def test_async_comprehension() -> None: | ||
xs = rx.from_iterable([1, 2, 3]) | ||
|
||
# result = [x async for x in to_async_iterable(xs)] | ||
result = [x async for x in rx.to_async_iterable(xs)] | ||
|
||
# assert result == [1, 2, 3] | ||
assert result == [1, 2, 3] | ||
|
||
|
||
# @pytest.mark.asyncio | ||
# async def test_async_iteration_aync_with() -> None: | ||
# xs = AsyncObservable.from_iterable([1, 2, 3]) | ||
# result = [] | ||
@pytest.mark.asyncio | ||
async def test_async_iteration_aync_with() -> None: | ||
xs = rx.from_iterable([1, 2, 3]) | ||
result = [] | ||
|
||
# obv = AsyncIteratorObserver() | ||
# async with subscribe(xs, obv): | ||
# async for x in obv: | ||
# result.append(x) | ||
obv = rx.AsyncIteratorObserver(xs) | ||
async for x in obv: | ||
result.append(x) | ||
|
||
# assert result == [1, 2, 3] | ||
assert result == [1, 2, 3] | ||
|
||
|
||
# @pytest.mark.asyncio | ||
# async def test_async_iteration_inception() -> None: | ||
# # iterable to async source to async iterator to async source | ||
# obv = AsyncIteratorObserver() | ||
@pytest.mark.asyncio | ||
async def test_async_iteration_inception() -> None: | ||
# iterable to async source to async iterator to async source | ||
xs = rx.from_iterable([1, 2, 3]) | ||
obv = rx.AsyncIteratorObserver(xs) | ||
|
||
# xs = AsyncObservable.from_iterable([1, 2, 3]) | ||
# await subscribe(xs, obv) | ||
# ys = from_async_iterable(obv) | ||
# result = [] | ||
ys = rx.from_async_iterable(obv) | ||
result = [] | ||
|
||
# async for y in to_async_iterable(ys): | ||
# result.append(y) | ||
async for y in rx.to_async_iterable(ys): | ||
result.append(y) | ||
|
||
# assert result == [1, 2, 3] | ||
|
||
|
||
# if __name__ == '__main__': | ||
# loop = asyncio.get_event_loop() | ||
# loop.run_until_complete(test_async_iteration_inception()) | ||
# loop.close() | ||
assert result == [1, 2, 3] |