-
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
03564f7
commit 8e4e721
Showing
2 changed files
with
21 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 |
---|---|---|
|
@@ -2,7 +2,12 @@ | |
import json | ||
import unittest | ||
|
||
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, | ||
|
@@ -562,7 +567,12 @@ def test_directly_setting_substitutions(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]' | ||
|
@@ -576,4 +586,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') |