Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #7773 -- Added some simple tests for EmailMessage. Thanks to se…

…rialx for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7975 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 825622d912aa8e87ddcda1af65edef9bb765e389 1 parent 69ac815
@freakboy3742 freakboy3742 authored
View
2  tests/regressiontests/mail/__init__.py
@@ -0,0 +1,2 @@
+
+
View
1  tests/regressiontests/mail/models.py
@@ -0,0 +1 @@
+# This file intentionally left blank
View
41 tests/regressiontests/mail/tests.py
@@ -0,0 +1,41 @@
+# coding: utf-8
+r"""
+# Tests for the django.core.mail.
+
+>>> from django.core.mail import EmailMessage
+
+# Test normal ascii character case:
+
+>>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com'])
+>>> message = email.message()
+>>> message['Subject']
+'Subject'
+>>> message.get_payload()
+'Content'
+>>> message['From']
+'from@example.com'
+>>> message['To']
+'to@example.com'
+
+# Test multiple-recipient case
+
+>>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com','other@example.com'])
+>>> message = email.message()
+>>> message['Subject']
+'Subject'
+>>> message.get_payload()
+'Content'
+>>> message['From']
+'from@example.com'
+>>> message['To']
+'to@example.com, other@example.com'
+
+# Test for header injection
+
+>>> email = EmailMessage('Subject\nInjection Test', 'Content', 'from@example.com', ['to@example.com'])
+>>> message = email.message()
+Traceback (most recent call last):
+ ...
+BadHeaderError: Header values can't contain newlines (got 'Subject\nInjection Test' for header 'Subject')
+
+"""
Please sign in to comment.
Something went wrong with that request. Please try again.