-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23bc052
commit 7eddee4
Showing
2 changed files
with
19 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
import json | ||
|
||
from email.message import EmailMessage | ||
try: | ||
from email.message import EmailMessage | ||
except ImportError: | ||
# Python2 | ||
from email import message | ||
EmailMessage = message.Message | ||
|
||
from sendgrid.helpers.mail import ( | ||
ASM, | ||
|
@@ -589,7 +594,12 @@ def test_dynamic_template_data(self): | |
|
||
def test_from_emailmessage(self): | ||
message = EmailMessage() | ||
message.set_content('message that is not urgent') | ||
body = 'message that is not urgent' | ||
try: | ||
message.set_content(body) | ||
except AttributeError: | ||
# Python2 | ||
message.set_payload(body) | ||
message.set_default_type('text/plain') | ||
message['Subject'] = 'URGENT TITLE' | ||
message['From'] = '[email protected]' | ||
|
@@ -603,4 +613,4 @@ def test_from_emailmessage(self): | |
self.assertEqual(len(mail.contents), 1) | ||
content = mail.contents[0] | ||
self.assertEqual(content.type, 'text/plain') | ||
self.assertEqual(content.value, 'message that is not urgent\n') | ||
self.assertEqual(content.value, 'message that is not urgent') |