[Twisted-Python] Stopping Reactor in UnitTest Callback
jml at mumak.net
Sat Jan 12 09:26:04 EST 2013
On Sat, Jan 12, 2013 at 2:00 PM, Fabian Rothfuchs
<fabian.rothfuchs at googlemail.com> wrote:
> I'm in the dilemma of using both - Django and Twisted.
> My goal is to have Django initialising the test (python manage.py test
> <appname>), instead of trial, as it will setup the whole test environment
> (I.e. Creates a db copy, allows per-model testing, follows certain
> conventions, etc).
> As to that I'm trying to find a way how to start/stop the reactor from the
> test, as trial is not executed.
> Do you have an idea or an approach how this could be realised?
One thing that works for us is to have our Twisted-using tests
subclass testtools.TestCase, and declare that they are asynchronous
run_tests_with = AsynchronousDeferredRunTest
d = foo.some_api()
Of course, not inheriting from Django's TestCase means you lose a lot
of its implicit set-up, but most of that can be called from public
APIs. We have a very rough project that does some of the
You could probably use twisted.trial.unittest.TestCase instead of
More information about the Twisted-Python