Skip to content

Instantly share code, notes, and snippets.

@jml
Last active February 2, 2016 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jml/114faf900f33abaf973a to your computer and use it in GitHub Desktop.
Save jml/114faf900f33abaf973a to your computer and use it in GitHub Desktop.
from twisted.trial.unittest import SynchronousTestCase
from twisted.internet.defer import gatherResults, maybeDeferred
class MyTests(SynchronousTestCase):
def test_catches_failure(self):
d = maybeDeferred(lambda: 1/0)
self.failureResultOf(d)
def test_gather_results_transparent(self):
# Fails with ZeroDivisionError
d = gatherResults([maybeDeferred(lambda: 1/0)])
self.failureResultOf(d)
@sarum90
Copy link

sarum90 commented Feb 2, 2016

For what it's worth, I'm not surprised at this. In doing my first project that I did with twisted (my submission to the ClusterHQ puzzle) I ran into 3 or 4 little hiccups like this when I tried to use twisted. I think this was actually one of them. I basically had to write my unit tests as if I didn't trust any of the twisted utilities 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment