diff --git a/django_mailbox/tests/base.py b/django_mailbox/tests/base.py index 5e50fa4..62541cb 100644 --- a/django_mailbox/tests/base.py +++ b/django_mailbox/tests/base.py @@ -1,9 +1,8 @@ import email -import os.path +import os +from os.path import dirname, join import time -import six - from django.conf import settings from django.test import TestCase @@ -16,14 +15,7 @@ class EmailIntegrationTimeout(Exception): def get_email_as_text(name): - with open( - os.path.join( - os.path.dirname(__file__), - 'messages', - name, - ), - 'rb' - ) as f: + with open(join(dirname(__file__), 'messages', name), 'rb') as f: return f.read() @@ -65,23 +57,9 @@ class EmailMessageTestCase(TestCase): return messages 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): - copy = self._get_email_as_text(name) - if six.PY3: - return email.message_from_bytes(copy) - else: - return email.message_from_string(copy) + with open(join(dirname(__file__), 'messages', name), 'rb') as f: + return email.message_from_files(f) def _headers_identical(self, left, right, header=None): """ Check if headers are (close enough to) identical. diff --git a/django_mailbox/tests/test_transports.py b/django_mailbox/tests/test_transports.py index aaa0d0d..8153a25 100644 --- a/django_mailbox/tests/test_transports.py +++ b/django_mailbox/tests/test_transports.py @@ -148,7 +148,7 @@ class TestPop3Transport(EmailMessageTestCase): '+OK message follows', [ line.encode('ascii') - for line in self._get_email_as_text( + for line in get_email_as_text( 'generic_message.eml' ).decode('ascii').split('\n') ],