sh_cpl/unittests/unittests_reactive_extenstions/observable_operator.py
2023-04-16 15:48:33 +02:00

28 lines
717 B
Python

import traceback
import unittest
from cpl_core.console import Console
from cpl_reactive_extensions.interval import Interval
from cpl_reactive_extensions.operators.take import take
class ObservableOperatorTestCase(unittest.TestCase):
def setUp(self):
self._error = False
self._completed = False
def _on_error(self, ex: Exception):
tb = traceback.format_exc()
Console.error(f"Got error from observable: {ex}", tb)
self._error = True
def _on_complete(self):
self._completed = True
def test_take_two(self):
def sub(x):
Console.write_line(x)
observable = Interval(0.1)
sub = observable.pipe(take(2)).subscribe(sub)