Skip to content

Commit

Permalink
Fix example for AsyncTestSubject
Browse files Browse the repository at this point in the history
  • Loading branch information
alhimik45 authored Jan 31, 2024
1 parent 3574d01 commit 41a9fb1
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,25 +370,23 @@ def event_loop():
yield loop
loop.close()


@pytest.mark.asyncio
async def test_delay_done():
xs = AsyncSubject() # Test stream

async def mapper(value):
return value * 10

ys = delay(0.5, xs)
lis = AsyncTestObserver() # Test AsyncAnonymousObserver
sub = await subscribe_async(ys, lis)
await xs.asend_later(0, 10)
await xs.asend_later(1, 20)
await xs.aclose_later(1)
await sub

assert lis.values == [
(0.5, OnNext(10)),
(1.5, OnNext(20)),
(2.5, OnCompleted)
xs = AsyncTestSubject()

ys = pipe(xs, rx.delay(1.0))
obv = AsyncTestObserver()
async with await ys.subscribe_async(obv):
await xs.asend_later(0, 10)
await xs.asend_later(1.0, 20)
await xs.aclose_later(1.0)
await obv

assert obv.values == [
(ca(1), OnNext(10)),
(ca(2), OnNext(20)),
(ca(3), OnCompleted()),
]
```

Expand Down

0 comments on commit 41a9fb1

Please sign in to comment.