>
>
> I strongly recommend you reconsider doing this.
>
> The Twisted core developers have, for several years now, mostly eschewed
> the usage of returning Deferreds from test cases. Instead, tests are
> written by explicitly controlling all events explicitly, with careful use
> of test doubles to replace certain features of the event loop. There’s also
> a class in Trial, “SynchronousTestCase”, which offers utilities such as
> synchronousResultOf(Deferred) -> result and synchronousFailureOf(Deferred)
> -> result, which both assume the Deferred has fired synchronously (which
> your test case can ensure). The testing philosophy in Twisted is: if you
> need the global event loop to really truly run, it’s not a unit test.
>
>
asyncio has the *run_until_complete* feature to handle asynchronous code in
a synchronous fashion.
You can create a bright new loop and run your stuff in it.
Pulsar test suite, for example, runs asynchronously, but test cases don't
necessarily depends on the thread-local (not global) event loop of the test
suite.


> Trial’s return-a-Deferred feature is still useful in certain integration
> test situations, where you really want to talk to the Internet or interact
> with the user in your set of test suites, but for unit tests, it’s possible
> to exercise all code paths before the test method returns.
>
>

I fear twisted global reactor is the problem here

Reply via email to