[Twisted-Python] Re: Reactor is left dirty after calling twisted.mail.smtp.sendmail via trial

Jean-Paul Calderone exarkun at divmod.com
Tue Feb 26 16:06:44 EST 2008

On Tue, 26 Feb 2008 20:33:12 +0100, Michał Pasternak <michal.dtz at gmail.com> wrote:
>Dnia 2008-02-26, o godz. 15:40:54
>Marcin Kasperski <Marcin.Kasperski at softax.com.pl> napisał(a):
>> > Am I wrong?
>> I took a deeper look. Looks like it is caused by the way smtp.py
>> works.
>> Not sure whether it is possible to do anything with that (without
>> rewriting the module deeply) :-(
>Let me ask the other way then - is it against testing philosophy to run
>functions like t.m.smtp.sendmail from the unittest? It is
>environment-dependent - however there are some cases when calling it
>from the test is useful.

Maybe so, but then it's not really a unit test, since by calling it you
have just included an entire SMTP server in the test along with whatever
else you're trying to test.  Still, maybe it's a good idea sometimes.  The
API was created a long time ago, and it's probably not ideal.  It is very
unfortunate that it gives you no way to know when it is really done.

>If I shouldn't even think about calling such functions from the
>unittest, maybe someone could point out a better method of testing?

Well...  I dunno what you're testing.  But you could make a fake (verified,
of course) of sendmail() and call that in your tests instead.


More information about the Twisted-Python mailing list