用于发送电子邮件的代码的单元测试工具。
mailtest的Python项目详细描述
mailtest是一个python单元测试库,用于发送电子邮件的代码。 它在pythonwith块中启动本地smtp服务器,并且 捕获发送到它的所有电子邮件。这些电子邮件可以在 街区。
示例:
with mailtest.Server() as mt: send_welcome_email() assert len(mt.emails) == 1
安装
pip3 install mailtest
配置
配置是通过kwargs到mailtest.Server()完成的。选项: smtp_port(默认值:1025)-sendgrid_port(默认值:None)
速度
MailTest可以在Intel(R)上测试每秒接收约4000封电子邮件 核心(TM)I5-7260U CPU@2.20GHz。
测试
$ python2 test.py .. ---------------------------------------------------------------------- Ran 2 tests in 0.269s OK
$ python3 test.py .. ---------------------------------------------------------------------- Ran 2 tests in 0.543s OK