From ff27d299cc50211de9596d3e1f1474508d588897 Mon Sep 17 00:00:00 2001 From: Maciej Fijalkowski Date: Wed, 24 Nov 2010 15:06:40 +0200 Subject: [PATCH] Finish the test --- testing/test_unittest.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/testing/test_unittest.py b/testing/test_unittest.py index c1f40ea88..1b42316a0 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -228,7 +228,7 @@ class TestTrialUnittest: def test_trial_error(self, testdir): testdir.makepyfile(""" from twisted.trial.unittest import TestCase - from twisted.internet.defer import inlineCallbacks + from twisted.internet.defer import Deferred from twisted.internet import reactor class TC(TestCase): @@ -238,13 +238,16 @@ class TestTrialUnittest: def test_two(self): def f(_): crash - - return reactor.callLater(0.3, f) + + d = Deferred() + d.addCallback(f) + reactor.callLater(0.3, d.callback, None) + return d def test_three(self): def f(): pass # will never get called - return reactor.callLater(0.3, f) + reactor.callLater(0.3, f) # will crash at teardown def test_four(self): @@ -252,7 +255,10 @@ class TestTrialUnittest: reactor.callLater(0.3, f) crash - return reactor.callLater(0.3, f) + d = Deferred() + d.addCallback(f) + reactor.callLater(0.3, d.callback, None) + return d # will crash both at test time and at teardown """) result = testdir.runpytest()