Skip to content

Commit

Permalink
Add rx generator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Feb 9, 2024
1 parent bcfd54a commit 2acaca3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/testreactive.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import asyncio
import math
import operator
import os
import unittest
import time

try:
import numpy as np
Expand Down Expand Up @@ -325,3 +327,29 @@ def debug(value):

assert namex.rx.pipe(debug).title().rx.value == 'Bob'
assert len(items) == 1

async def test_reactive_gen():
def gen():
yield 1
time.sleep(0.1)
yield 2

rxgen = rx(gen)
assert rxgen.rx.value is param.Undefined
await asyncio.sleep(0.05)
assert rxgen.rx.value == 1
await asyncio.sleep(0.1)
assert rxgen.rx.value == 2

async def test_reactive_async_gen():
async def gen():
yield 1
await asyncio.sleep(0.1)
yield 2

rxgen = rx(gen)
assert rxgen.rx.value is param.Undefined
await asyncio.sleep(0.05)
assert rxgen.rx.value == 1
await asyncio.sleep(0.1)
assert rxgen.rx.value == 2

0 comments on commit 2acaca3

Please sign in to comment.