[Dev] Mock Reactor for tests?
Phillip J. Eby
pje at telecommunity.com
Mon Jun 6 12:30:55 PDT 2005
At 11:59 AM 6/6/2005 -0700, Brian Kirsch wrote:
>Hi Phillip,
>I am not sure if we really need the mock reactor. Twisted provides very
>good trial test support for creating local loopbacks between
>Twisted clients and Twisted servers. What is the issue with run and stop
>of a reactor? To my knowledge this should not be a problem.
I'm not personally aware of one, but there were references to such problems
in past OSAF IRC logs and commit messages, that I assumed were based on
OSAF experience.
>Also if all the unit tests were running in the same process why would you
>need to stop and start the reactor?
Maybe you and Heikki need to get together to see if there is actually a
problem, then. :)
>I have attached my recent submissions to twisted core which include a
>pop3TestServer, a pop3Client, and a unittest illustrating how to set up
>local client server communication.
>
>Thoughts?
As I mentioned, the last time I hacked on Twisted was a couple of years
ago, but as recently as 2004 it was reported that Twisted doesn't support
"simulated time" in the reactor. If we need simulated-time tests, it might
be worth implementing the 'installClock()/now()' methods that were
suggested in the posting I referenced.
At the time I last worked with Twisted, I don't think twisted.trial even
existed, and I hadn't looked at it until now. I'll need to take a closer
look at it if we're going to use it with run_tests, as it looks at first
glance like twisted.trial re-implements its own incompatible version of the
Python unittest module.
I'll take a look at it some more when I have some downtime, but my first
impression is to worry when I see comments like "it is crappy crap, awful
dreadful crap" (in twisted.trial.runner). ;) Anyway, it'll probably take
a bit of work to integrate with the built-in unittest facility, as it
doesn't look like it was ever designed to. :( Also, I've already spotted
at least one apparent typo/bug ("moudleName" where "moduleName" was
apparently intended). On the plus side, however, trial is interface-based,
so that might help a lot in getting it integrated.
More information about the Dev
mailing list