unit testing a routine that sends mail
commander_coder
commander_coder at hotmail.com
Thu Feb 18 10:59:14 EST 2010
On Feb 18, 10:27 am, Bruno Desthuilliers <bruno.
42.desthuilli... at websiteburo.invalid> wrote:
> you could just mock the send_mail
> function to test that your app does send the appropriate mail - which is
> what you really want to know.
That's essentially what I think I am doing.
I need to send a relatively complex email, multipart, with both a
plain text and html versions of a message, and some attachments. I am
worried that the email would fail to get out for some reason (say,
attaching the html message fails), so I want to test it. I started
out with a simple email, thinking to get unit tests working and then
as I add stuff to the email I'd run the tests to see if it broke
anything.
I could mock the send_mail function by having it print to the screen
"mail sent" or I could have a unit test that looked for the mail. I
did the first, and it worked fine. I thought to do the second,
starting with a unit test checking simply that the message got to the
mailbox. But I am unable to check that, as described in the original
message.
Jim
More information about the Python-list
mailing list