[Zope3-dev] Re: [Zope3-checkins] CVS:
Zope3/lib/python/Zope/App/OFS/Services/SmtpService/Views - __init__.py:1.1
configure.zcml:1.1
Leonardo Rochael Almeida
leo@hiper.com.br
28 Oct 2002 12:51:25 -0200
On Mon, 2002-10-28 at 10:45, Guido van Rossum wrote:
> > > Does it just use smtplib to send the mail? Perhaps the right approach
> > > would be to replace smtplib with a stub that records the calls into
> > > the library so the result can be checked for sanity. The replacement
> > > could be inserted during the setup and replaced in the teardown.
> >
> > Right. This would require hacking sys.modules.
>
> Or changing the API slightly so that the SMTP class can be passed in
> rather than always importing it from smtplib.
That's the spirit of XP's "test everything". Not all code can be easily
tested, but all code can be refactored in a way that makes it easy to
test.
I think the Python "default argument" feature helps a lot in this
regard.
--
Ideas don't stay in some minds very long because they don't like
solitary confinement.