Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. """
  2. During tests every outgoing email instead of being sent
  3. to outer world is saved in django.core.mail.outbox.
  4. """
  5.  
  6. from django.core import mail
  7.  
  8. def test_send_mail():
  9. mail.send_mail(
  10. 'Example subject',
  11. 'Message body.'
  12. 'from@example.net',
  13. ['to@example.net']
  14. )
  15.  
  16. assert len(mail.outbox) == 1, "Inbox is not empty"
  17. assert mail.outbox[0].subject == 'Example subject'
  18. assert mail.outbox[0].body == 'Message body.'
  19. assert mail.outbox[0].from_email == 'from@example.net'
  20. assert mail.outbox[0].to == ['to@example.net']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement