Esempio n. 1
0
 def test_errbackResultChangesValue(self):
     """
     The result of an errback affects the result returned from
     C{synchronize}.
     """
     sd = SynchronousDeferred(SynchronousFailure(RuntimeError()))
     sd.addErrback(lambda r: 42)
     self.assertEquals(sd.synchronize(), 42)
Esempio n. 2
0
 def test_errbackResultChangesNextCallbackArgument(self):
     """
     The result of an errback affects the argument passed to the next
     callback.
     """
     sd = SynchronousDeferred(SynchronousFailure(RuntimeError()))
     sd.addErrback(lambda r: 42)
     l = []
     sd.addCallback(l.append)
     self.assertEquals(l, [42])
Esempio n. 3
0
 def test_errorRaisingErrback(self):
     """
     If an errback raises an exception, errbacks will be called.
     """
     sd = SynchronousDeferred(SynchronousFailure(RuntimeError()))
     def errback(ignored):
         1/0
     sd.addErrback(errback)
     l = []
     sd.addErrback(l.append)
     self.assertEquals(len(l), 1)
     self.assertTrue(l[0].check(ZeroDivisionError))
Esempio n. 4
0
 def test_errorRaisingCallback(self):
     """
     If a callback raises an exception, errbacks will be called.
     """
     sd = SynchronousDeferred("foo")
     def callback(ignored):
         1/0
     sd.addCallback(callback)
     l = []
     sd.addErrback(l.append)
     self.assertEquals(len(l), 1)
     self.assertTrue(l[0].check(ZeroDivisionError))
Esempio n. 5
0
 def test_addErrback(self):
     """
     C{addErrback} immediately calls the errback when the current result is
     a failure.
     """
     failure = SynchronousFailure(RuntimeError())
     sd = SynchronousDeferred(failure)
     l = []
     self.assertEquals(sd.addErrback(l.append), sd)
     self.assertEquals(l, [failure])