On Tuesday, July 22, 2014 1:54:08 PM UTC+1, Tobias Oberstein wrote: > > Hi, > > I am maintaining AutobahnPython, a library that supports Twisted and > asyncio/Trollius in one codebase. > > Now, ideally, I'd like to write unit tests that work across all variants > - while avoiding code dups. > > In Twisted, there is Trial, which provides an extended version of > unittest.TestCase with this feature: > > """ > The main unique feature of this testing class is the ability to return a > ​Deferred from a test-case method. A test method which returns a > Deferred will not complete until that Deferred has fired; the reactor > will be automatically set up and run for you, along with a timeout to > make sure that tests don't run forever. If the Deferred fires > successfully, the test passes. If it fires with an error, the test > fails. This makes it possible to easily unit-test asynchronous > event-driven code, or to use Twisted APIs that return Deferreds in order > to write automated functional tests that communicate with a live running > service. > """ > http://twistedmatrix.com/trac/wiki/TwistedTrial > > I am wondering if there are any plans to add something similar to > asyncio/Trollius. That is: > > a) an extended TestCase base class > b) a test driver (analog of "trial" command) >
Pulsar has an asynchronous testing framework too http://quantmind.github.io/pulsar/apps/test.html It uses the unittest.TestCase class from the standard library but can handle test functions which return generators or asyncio/trollius Futures. It should work with twisted with the tx decorator documented here http://quantmind.github.io/pulsar/tutorials/webmail.html
