[Twisted-Python] how to unittest the deferred
exarkun at divmod.com
Wed Sep 28 21:35:11 EDT 2005
On Thu, 29 Sep 2005 10:28:31 +0900, Hyungyong Kim <yong27 at gmail.com> wrote:
>I'm newbie of Twisted. It's my first posting to this mail list. I'm
>sorry for my stupid question.
>Because I'm not familiar with asnyc programming, I'm suffering with
>deferred. So I want to make unittest to check result easily as follow.
>from twisted.trial import unittest
>from twisted.internet import defer, reactor
> d = defer.Deferred()
> return d
> return "result"
> def test1(self):
> self.assertEquals('result', unittest.deferredResult(someFunction()))
>But this test is not working. How can I check the "result" value.
>Thanks for your kind support.
I'm not entirely certain why the above doesn't work, although I could make some good guesses. Here's the preferred way to write such a test:
d = someFunction()
More information about the Twisted-Python