I have a ticket open for allowing tests that look like this, where each run has a new reactor instance:
def test_somethingShouldHappen(self, reactor): result = [] reactor.listenTCP(...) self.runReactor(reactor) self.assertEqual(result, ["hooray"]) Further thought suggests however that this doesn't add much, necessarily, over the current "return a Deferred" idiom for most users. Experience with ReactorBuilder framework that has similar testing mechanism suggests it's far too easy to fail to stop the reactor. Moreover, things like coiterate() don't work since they rely on pre-imported global reactor, and given the "from twisted.internet import reactor" idiom this testing style won't work well for many people's code. But! ReactorBuilder tests are superior in one way: no DirtyReactorWarning. You don't have to wait until all connections are closed, which is difficult, or make sure to cancel every timeout. This makes test writing simpler. Perhaps we should get rid of DirtyReactorWarning for regular Deferred-returning tests as well, then. We have all the infrastructure we need, after all, for canceling scheduled events and disconnecting all descriptors. We might want to log when we do so, to help debug things, but we already have cleanup code mostly implemented in trial anyway, and it seems like DirtyReactorWarning doesn't usually make future tests fail anyway since we do run cleanup. Threaded code might still be a problem, but that's the case for current tests now, and even switching to a new style of tests as above would only somewhat mitigate the issue. Thoughts? _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python