https://github.com/keredson/mailtest
A tool to unit test code that sends email.
https://github.com/keredson/mailtest
Last synced: about 1 year ago
JSON representation
A tool to unit test code that sends email.
- Host: GitHub
- URL: https://github.com/keredson/mailtest
- Owner: keredson
- License: lgpl-2.1
- Created: 2017-08-03T18:01:09.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-05-21T16:28:58.000Z (about 8 years ago)
- Last Synced: 2025-03-26T09:51:10.848Z (over 1 year ago)
- Language: Python
- Size: 14.6 KB
- Stars: 2
- Watchers: 3
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MailTest
MailTest is a Python unittesting library that for code that sends email. It starts a local SMTP server inside a Python `with` block, and captures all the email sent to it. These emails can then be read within the block.
Example:
```
with mailtest.Server() as mt:
send_welcome_email()
assert len(mt.emails) == 1
```
## Install
```
pip3 install mailtest
```
## Configuration
Configuration is done via kwargs to `mailtest.Server()`. Options:
- `smtp_port` (default: 1025)
- `sendgrid_port` (default: `None`)
## Speed
MailTest can test receive approx. 4000 emails/second on an Intel(R) Core(TM) i5-7260U CPU @ 2.20GHz.
## Testing
```
$ python2 test.py
..
----------------------------------------------------------------------
Ran 2 tests in 0.269s
OK
```
```
$ python3 test.py
..
----------------------------------------------------------------------
Ran 2 tests in 0.543s
OK
```