mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-10 06:48:19 +02:00
Merge 0a532bbf53 into ce6ce6b5dd
This commit is contained in:
commit
bbbfc71392
2 changed files with 9 additions and 27 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import email
|
import email
|
||||||
import os.path
|
import os
|
||||||
|
from os.path import dirname, join
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
@ -16,14 +16,7 @@ class EmailIntegrationTimeout(Exception):
|
||||||
|
|
||||||
|
|
||||||
def get_email_as_text(name):
|
def get_email_as_text(name):
|
||||||
with open(
|
with open(join(dirname(__file__), 'messages', name), 'r') as f:
|
||||||
os.path.join(
|
|
||||||
os.path.dirname(__file__),
|
|
||||||
'messages',
|
|
||||||
name,
|
|
||||||
),
|
|
||||||
'rb'
|
|
||||||
) as f:
|
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -69,23 +62,12 @@ class EmailMessageTestCase(TestCase):
|
||||||
return messages
|
return messages
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
def _get_email_as_text(self, name):
|
|
||||||
with open(
|
|
||||||
os.path.join(
|
|
||||||
os.path.dirname(__file__),
|
|
||||||
'messages',
|
|
||||||
name,
|
|
||||||
),
|
|
||||||
'rb'
|
|
||||||
) as f:
|
|
||||||
return f.read()
|
|
||||||
|
|
||||||
def _get_email_object(self, name):
|
def _get_email_object(self, name):
|
||||||
copy = self._get_email_as_text(name)
|
with open(join(dirname(__file__), 'messages', name), 'r') as f:
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
return email.message_from_bytes(copy)
|
return email.message_from_binary_file(f)
|
||||||
else:
|
else:
|
||||||
return email.message_from_string(copy)
|
return email.message_from_file(f)
|
||||||
|
|
||||||
def _headers_identical(self, left, right, header=None):
|
def _headers_identical(self, left, right, header=None):
|
||||||
""" Check if headers are (close enough to) identical.
|
""" Check if headers are (close enough to) identical.
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ class TestPop3Transport(EmailMessageTestCase):
|
||||||
'+OK message follows',
|
'+OK message follows',
|
||||||
[
|
[
|
||||||
line.encode('ascii')
|
line.encode('ascii')
|
||||||
for line in self._get_email_as_text(
|
for line in get_email_as_text(
|
||||||
'generic_message.eml'
|
'generic_message.eml'
|
||||||
).decode('ascii').split('\n')
|
).decode('ascii').split('\n')
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue