clarify version support (2.7 is unsupported) and show that policies did not exist before 3.3

This commit is contained in:
Benson Tucker
2016-12-05 18:57:23 -05:00
parent 7e836fc81b
commit 096554342c
2 changed files with 9 additions and 3 deletions

View File

@@ -3,7 +3,11 @@ from __future__ import unicode_literals
import unittest
from imbox.parser import *
from email.policy import SMTP
import sys
if sys.version_info.major < 3 or sys.version_info.minor < 3:
SMTP = False
else:
from email.policy import SMTP
raw_email = """Delivered-To: johndoe@gmail.com
@@ -106,7 +110,7 @@ class TestParser(unittest.TestCase):
def test_decode_mail_header(self):
pass
def test_get_mail_addresses(self):
to_message_object = email.message_from_string("To: John Doe <johndoe@gmail.com>")
@@ -116,6 +120,9 @@ class TestParser(unittest.TestCase):
self.assertEqual([{'email': 'johnsmith@gmail.com', 'name': 'John Smith'}], get_mail_addresses(from_message_object, 'from'))
def test_parse_email_with_policy(self):
if not SMTP:
return
message_object = email.message_from_bytes(
raw_email_encoded_needs_refolding,
policy=SMTP.clone(refold_source='all')