Skip to content

Commit

Permalink
Merge pull request #46 from alhimik45/patch-1
Browse files Browse the repository at this point in the history
Update outdated and broken example for AsyncTestSubject
  • Loading branch information
dbrattli committed Feb 25, 2024
2 parents 3574d01 + 18e71c7 commit cf8bcb8
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,23 +372,20 @@ def event_loop():

@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() # Test stream

ys = pipe(xs, rx.delay(1.0))
obv = AsyncTestObserver() # Test AsyncAnonymousObserver
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 cf8bcb8

Please sign in to comment.