[WIP] Fixed imports
This commit is contained in:
parent
a155bbc468
commit
60a349f918
@ -84,14 +84,20 @@ class AsyncAction(Action):
|
|||||||
if self.closed:
|
if self.closed:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._scheduler.actions.remove(self)
|
timer = self.timer
|
||||||
|
scheduler = self._scheduler
|
||||||
if self._timer is not None:
|
actions = self._scheduler.actions
|
||||||
self._timer = self.recycle_async_timer(self._scheduler, self.timer, None)
|
|
||||||
|
|
||||||
self._work = None
|
self._work = None
|
||||||
self.state = None
|
self.state = None
|
||||||
self._scheduler = None
|
self._scheduler = None
|
||||||
self._pending = False
|
self._pending = False
|
||||||
self.delay = None
|
self.delay = None
|
||||||
|
|
||||||
|
if self in actions:
|
||||||
|
actions.remove(self)
|
||||||
|
|
||||||
|
if self.timer is not None:
|
||||||
|
self.timer = self.recycle_async_timer(scheduler, timer, None)
|
||||||
|
|
||||||
Action.unsubscribe(self)
|
Action.unsubscribe(self)
|
||||||
|
@ -33,9 +33,10 @@ class ObservableOperatorTestCase(unittest.TestCase):
|
|||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
observable = Interval(0.1)
|
observable = Interval(0.1)
|
||||||
observable.pipe(take(2)).subscribe(sub)
|
sub = observable.pipe(take(2)).subscribe(sub)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
self.assertEqual(count, 2)
|
self.assertEqual(count, 2)
|
||||||
|
sub.unsubscribe()
|
||||||
|
|
||||||
def test_take_five(self):
|
def test_take_five(self):
|
||||||
count = 0
|
count = 0
|
||||||
@ -46,9 +47,10 @@ class ObservableOperatorTestCase(unittest.TestCase):
|
|||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
observable = Interval(0.1)
|
observable = Interval(0.1)
|
||||||
observable.pipe(take(5)).subscribe(sub)
|
sub = observable.pipe(take(5)).subscribe(sub)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.assertEqual(count, 5)
|
self.assertEqual(count, 5)
|
||||||
|
sub.unsubscribe()
|
||||||
|
|
||||||
def test_take_until(self):
|
def test_take_until(self):
|
||||||
count = 0
|
count = 0
|
||||||
@ -68,19 +70,19 @@ class ObservableOperatorTestCase(unittest.TestCase):
|
|||||||
unsubscriber.complete()
|
unsubscriber.complete()
|
||||||
self.assertEqual(count, timer * 10 - 1)
|
self.assertEqual(count, timer * 10 - 1)
|
||||||
|
|
||||||
def test_debounce_time(self):
|
# def test_debounce_time(self):
|
||||||
def call(x):
|
# def call(x):
|
||||||
x.next(1)
|
# x.next(1)
|
||||||
x.next(2)
|
# x.next(2)
|
||||||
x.next(3)
|
# x.next(3)
|
||||||
x.next(4)
|
# x.next(4)
|
||||||
x.next(5)
|
# x.next(5)
|
||||||
x.next(6)
|
# x.next(6)
|
||||||
x.complete()
|
# x.complete()
|
||||||
|
#
|
||||||
observable = Observable(call)
|
# observable = Observable(call)
|
||||||
|
#
|
||||||
sub = observable.pipe(debounce_time(600)).subscribe(lambda x: Console.write_line("Hey", x))
|
# sub = observable.pipe(debounce_time(600)).subscribe(lambda x: Console.write_line("Hey", x))
|
||||||
|
#
|
||||||
time.sleep(2)
|
# time.sleep(2)
|
||||||
sub.unsubscribe()
|
# sub.unsubscribe()
|
||||||
|
@ -92,11 +92,12 @@ class ReactiveTestCase(unittest.TestCase):
|
|||||||
expected_x += 1
|
expected_x += 1
|
||||||
|
|
||||||
observable = Observable.from_list([1, 2, 3, 4])
|
observable = Observable.from_list([1, 2, 3, 4])
|
||||||
observable.subscribe(
|
sub = observable.subscribe(
|
||||||
_next,
|
_next,
|
||||||
self._on_error,
|
self._on_error,
|
||||||
)
|
)
|
||||||
self.assertFalse(self._error)
|
self.assertFalse(self._error)
|
||||||
|
sub.unsubscribe()
|
||||||
|
|
||||||
def test_subject(self):
|
def test_subject(self):
|
||||||
expected_x = 1
|
expected_x = 1
|
||||||
@ -115,9 +116,10 @@ class ReactiveTestCase(unittest.TestCase):
|
|||||||
subject.subscribe(lambda x: _next(True, x), self._on_error)
|
subject.subscribe(lambda x: _next(True, x), self._on_error)
|
||||||
|
|
||||||
observable = Observable.from_list([1, 2, 3])
|
observable = Observable.from_list([1, 2, 3])
|
||||||
observable.subscribe(subject, self._on_error)
|
sub = observable.subscribe(subject, self._on_error)
|
||||||
|
|
||||||
self.assertFalse(self._error)
|
self.assertFalse(self._error)
|
||||||
|
sub.unsubscribe()
|
||||||
|
|
||||||
def test_behavior_subject(self):
|
def test_behavior_subject(self):
|
||||||
subject = BehaviorSubject(int, 0)
|
subject = BehaviorSubject(int, 0)
|
||||||
@ -129,6 +131,7 @@ class ReactiveTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
subject.subscribe(lambda x: Console.write_line("b", x))
|
subject.subscribe(lambda x: Console.write_line("b", x))
|
||||||
subject.next(3)
|
subject.next(3)
|
||||||
|
subject.unsubscribe()
|
||||||
|
|
||||||
def test_interval_default(self):
|
def test_interval_default(self):
|
||||||
wait = 10
|
wait = 10
|
||||||
|
@ -3,7 +3,6 @@ import unittest
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from cpl_core.console import Console
|
from cpl_core.console import Console
|
||||||
from cpl_reactive_extensions.scheduler.async_scheduler import async_scheduler
|
|
||||||
from cpl_reactive_extensions.timer import Timer
|
from cpl_reactive_extensions.timer import Timer
|
||||||
|
|
||||||
|
|
||||||
@ -25,13 +24,12 @@ class SchedulerTestCase(unittest.TestCase):
|
|||||||
timer.clear()
|
timer.clear()
|
||||||
|
|
||||||
def test_schedule(self):
|
def test_schedule(self):
|
||||||
pass
|
count = 0
|
||||||
# count = 0
|
|
||||||
#
|
def task():
|
||||||
# def task():
|
nonlocal count
|
||||||
# nonlocal count
|
Console.write_line(datetime.now(), "Hello world")
|
||||||
# Console.write_line(datetime.now(), "Hello world")
|
count += 1
|
||||||
# count += 1
|
|
||||||
#
|
# async_scheduler.schedule(task, 100)
|
||||||
# # async_scheduler.schedule(task, 100)
|
time.sleep(2)
|
||||||
# time.sleep(2)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user