1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-09 22:38:19 +02:00

Actually fixing Python 3 support; verified both IMAP and POP3. Fixes #13 (seriously this time).

This commit is contained in:
Adam Coddington 2014-04-25 16:37:51 -07:00
parent 4002d5c222
commit 3b2d60a903
9 changed files with 145 additions and 16 deletions

View file

@ -1,8 +1,9 @@
import email
import os.path
import six
from django.test import TestCase
import sys
from django_mailbox import models
from django_mailbox.models import Mailbox, Message
@ -22,7 +23,7 @@ class EmailMessageTestCase(TestCase):
self.mailbox = Mailbox.objects.create()
super(EmailMessageTestCase, self).setUp()
def _get_email_object(self, name):
def _get_email_as_text(self, name):
with open(
os.path.join(
os.path.dirname(__file__),
@ -31,10 +32,14 @@ class EmailMessageTestCase(TestCase):
),
'rb'
) as f:
if sys.version_info < (3, 0):
return email.message_from_string(f.read())
else:
return email.message_from_bytes(f.read())
return f.read()
def _get_email_object(self, name):
copy = self._get_email_as_text(name)
if six.PY3:
return email.message_from_bytes(copy)
else:
return email.message_from_string(copy)
def _headers_identical(self, left, right, header=None):
""" Check if headers are (close enough to) identical.