Jan-Wijbrand Kolman wrote:
> Zope.sendmail explains in its README.txt that the developer using 
> zope.sendmail should himself take care of not sending emails (by setting 
> up a test layer for example, that would register a no-op IMailDelivery 
> utility).

Why not just use testfixtures [1] and Mock [2] to replace the SMTP class 
in your testcase?

from mock import Mock
from testfixtures import replace
def test_mystuff(self):

That way you can check the right smtp calls are made, if you want to, 
and there's no chance of mail being sent?

If you're doing a lot of tests, you might want to do:

from mock import Mock
from testfixtures import Replacer

class MyTests(TestCase):

    def setUp(self):
      self.r = Replacer

    def tearDown(self):

This latter technique would probably work in a Layer too...



[1] http://pypi.python.org/pypi/testfixtures

[2] http://pypi.python.org/pypi/mock

Simplistix - Content Management, Batch Processing & Python Consulting
            - http://www.simplistix.co.uk
Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to