On Sat, Jan 12, 2013 at 2:00 PM, Fabian Rothfuchs <fabian.rothfu...@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[1], and declare that they are asynchronous Twisted tests. e.g. class TestTwistedAPI(testtools.TestCase): run_tests_with = AsynchronousDeferredRunTest def test_foo(self): d = foo.some_api() d.addCallback(self.assertEqual, "bar") return d 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 necessaries.[2] You could probably use twisted.trial.unittest.TestCase instead of testtools.TestCase. cheers, jml [1] http://pypi.python.org/pypi/testtools [2] http://pypi.python.org/pypi/djangofixture _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python