Improved imports

This commit is contained in:
Sven Heidemann 2023-04-16 00:57:35 +02:00
parent 51803bf5d1
commit 79a6c1db8f
3 changed files with 36 additions and 1 deletions

View File

@ -19,8 +19,14 @@ __version__ = "2023.4.dev170"
from collections import namedtuple
# imports
from .behavior_subject import BehaviorSubject
from .interval import Interval
from .observable import Observable
from .subject import Subject
from .subscriber import Subscriber
from .subscription import Subscription
from .type import ObserverOrCallable
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="2023", minor="4", micro="dev170")

View File

@ -21,6 +21,11 @@ from collections import namedtuple
# imports
from .observer import Observer
from .operator import Operator
from .subscribable import Subscribable
from .unsubscribable import Unsubscribable
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="2023", minor="4", micro="dev170")

View File

@ -148,3 +148,27 @@ class ReactiveTestCase(unittest.TestCase):
sub.unsubscribe()
end = datetime.now()
self.assertEqual(round((end - start).total_seconds()), wait)
def test_interval_custom(self):
wait = 10
i = 0
n = 0
def callback(x: Observer):
nonlocal n
x.next(n)
n += 1
def test_sub(x):
nonlocal i
self.assertEqual(x, i)
i += 1
observable = Interval(1.0, callback)
sub = observable.subscribe(test_sub)
start = datetime.now()
time.sleep(wait)
sub.unsubscribe()
end = datetime.now()
self.assertEqual(round((end - start).total_seconds()), wait)