Ejemplo n.º 1
0
 def test_failure(self):
     # _spinner.extract_result raises the failure's exception if it's given
     # a Deferred that is failing.
     try:
         1/0
     except ZeroDivisionError:
         f = Failure()
     d = defer.fail(f)
     self.assertThat(
         lambda: extract_result(d),
         Raises(MatchesException(ZeroDivisionError)))
Ejemplo n.º 2
0
 def _run_user(self, function, *args):
     d = defer.maybeDeferred(function, *args)
     d.addErrback(self._got_user_failure)
     result = extract_result(d)
     return result
Ejemplo n.º 3
0
 def _run_user(self, function, *args):
     d = defer.maybeDeferred(function, *args)
     d.addErrback(self._got_user_failure)
     result = extract_result(d)
     return result
Ejemplo n.º 4
0
 def test_success(self):
     # _spinner.extract_result returns the value of the Deferred if it has
     # fired successfully.
     marker = object()
     d = defer.succeed(marker)
     self.assertThat(extract_result(d), Equals(marker))
Ejemplo n.º 5
0
 def test_not_fired(self):
     # _spinner.extract_result raises _spinner.DeferredNotFired if it's
     # given a Deferred that has not fired.
     self.assertThat(
         lambda: extract_result(defer.Deferred()),
         Raises(MatchesException(DeferredNotFired)))