[TIP] Testing asynchronous method

Jonathan Lange jml at mumak.net
Sat Oct 22 02:48:10 PDT 2011


On Fri, Oct 21, 2011 at 6:30 PM, Chris Withers <chris at simplistix.co.uk> wrote:
> On 18/10/2011 18:55, Jonathan Lange wrote:
>>
>> On Tue, Oct 18, 2011 at 6:40 PM, Pere Martir<pere.martir4 at gmail.com>
>>  wrote:
>>>
>>> I want to test if a callback is called within a predefined time. I am
>>> surprised that I cannot find a simple solution on Internet.
>>>
>>> I don't want to use Twisted Trial or tornado.testing but only Python
>>> built-in unittest, is it possible ? I am developing  an asynchronous
>>> library by TDD, and I don't want to depend on Twisted or Tornado.
>>>
>>
>> Yeah, it's possible, but you'll be re-implementing Twisted Trial for
>> whatever asynchronous system you are using.
>>
>> I'm biased, but I'd strongly recommend using Twisted Trial or
>> something else that already exists.
>
> I thought all the clever was embedded in twisted's TestCase class?
>

Yeah, that's correct. We try to be compatible with unittest, so most
runners should work (but we don't actually test for this). Certainly
works with zope.testrunner.

(See also testtools, where all the clever is separated from the
TestCase: http://testtools.rtfd.org/)

jml



More information about the testing-in-python mailing list