Using lettuce, how can I verify that an email sent from a Django web application has the correct contents?

时光毁灭记忆、已成空白 提交于 2019-12-04 17:31:59

You can use django.core.mail.outbox as described in django docs https://docs.djangoproject.com/en/dev/topics/testing/#email-services

from django.core import mail

assert len(mail.outbox) == 1
assert mail.outbox[0].subject == 'Subject here'

Lettuse uses django.test.utils.setup_test_environment that overrides email backend to the locmem email backend.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!