def test_on_error_accept_action_with_result(): ex = 'ex' n1 = OnError(ex) def on_next(x): assert(False) return None def on_error(ex): return "OK" def on_completed(): assert(False) return None res = n1.accept(on_next, on_error, on_completed) assert('OK' == res)
def test_on_error_accept_action_with_result(): ex = 'ex' n1 = OnError(ex) def on_next(x): assert (False) return None def on_error(ex): return "OK" def on_completed(): assert (False) return None res = n1.accept(on_next, on_error, on_completed) assert ('OK' == res)
def test_on_error_accept_action(): ex = 'ex' obs = [False] n1 = OnError(ex) def on_next(x): assert(False) return None def on_error(ex): obs[0] = True return obs[0] def on_completed(): assert(False) return None n1.accept(on_next, on_error, on_completed) assert(obs[0])
def test_on_error_accept_action(): ex = 'ex' obs = False n1 = OnError(ex) def on_next(x): assert(False) return None def on_error(ex): nonlocal obs obs = True return obs def on_completed(): assert(False) return None n1.accept(on_next, on_error, on_completed) assert(obs)
def test_on_error_equality(): ex1 = 'ex1' ex2 = 'ex2' n1 = OnError(ex1) n2 = OnError(ex1) n3 = OnError(ex2) n4 = OnCompleted() assert(n1.equals(n1)) assert(n1.equals(n2)) assert(n2.equals(n1)) assert(not n1.equals(None)) assert(not n1.equals(n3)) assert(not n3.equals(n1)) assert(not n1.equals(n4)) assert(not n4.equals(n1))
def test_on_error_accept_action(): ex = 'ex' obs = [False] n1 = OnError(ex) def on_next(x): assert (False) return None def on_error(ex): obs[0] = True return obs[0] def on_completed(): assert (False) return None n1.accept(on_next, on_error, on_completed) assert (obs[0])
def test_on_error_accept_action(): ex = 'ex' obs = False n1 = OnError(ex) def on_next(x): assert (False) return None def on_error(ex): nonlocal obs obs = True return obs def on_completed(): assert (False) return None n1.accept(on_next, on_error, on_completed) assert (obs)
def test_to_notifier_forwards(): obsn = MyObserver() obsn.to_notifier()(OnNext(42)) assert (obsn.has_on_next == 42) ex = 'ex' obse = MyObserver() obse.to_notifier()(OnError(ex)) assert (ex == obse.has_on_error) obsc = MyObserver() obsc.to_notifier()(OnCompleted()) assert (obsc.has_on_completed)
def on_error(self, exception): self.messages.append(Recorded(self.scheduler.clock, OnError(exception)))
def test_on_error_accept_observer(): ex = 'ex' obs = CheckOnErrorObserver() n1 = OnError(ex) n1.accept(obs) assert(ex == obs.error)
def on_error(cls, ticks, exception): if isinstance(exception, types.FunctionType): return Recorded(ticks, OnErrorPredicate(exception)) return Recorded(ticks, OnError(exception))
def test_on_error_accept_observer(): ex = 'ex' obs = CheckOnErrorObserver() n1 = OnError(ex) n1.accept(obs) assert (ex == obs.error)
def test_on_error_tostring(): ex = 'ex' n1 = OnError(ex) assert ("OnError" in str(n1)) assert ("ex" in str(n1))
def test_on_error_equality(): ex1 = 'ex1' ex2 = 'ex2' n1 = OnError(ex1) n2 = OnError(ex1) n3 = OnError(ex2) n4 = OnCompleted() assert (n1.equals(n1)) assert (n1.equals(n2)) assert (n2.equals(n1)) assert (not n1.equals(None)) assert (not n1.equals(n3)) assert (not n3.equals(n1)) assert (not n1.equals(n4)) assert (not n4.equals(n1))
def test_on_error_ctor_and_props(): e = 'e' n = OnError(e) assert ('E' == n.kind) assert (not n.has_value) assert (e == n.exception)
def on_error(exception): observer.on_next(OnError(exception)) observer.on_completed()
def on_error(cls, ticks, exception): if type(exception) == types.FunctionType: return Recorded(ticks, OnErrorPredicate(exception)) return Recorded(ticks, OnError(exception))
def create(): return OnError(ex).to_observable(scheduler)