[Zope3-dev] Re: [Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/SmtpService/Views - __init__.py:1.1 configure.zcml:1.1

Steve Alexander steve@cat-box.net
Mon, 28 Oct 2002 10:50:06 +0000


>> 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.

When a module just imports smtplib, yes.

However, in this case I think it makes sense to make the module allow 
for testing by giving it an API where you can choose how the name 
'smtplib' is resolved.

I don't see anything wrong with making allowances in the code to let it 
be tested, provided these allowances are not too intrusive.

--
Steve Alexander