Skip to content

Commit c7a8c81

Browse files
committed
Remove pre-Django 1.8 compatibility code
1 parent 1372ef2 commit c7a8c81

File tree

7 files changed

+18
-66
lines changed

7 files changed

+18
-66
lines changed

anymail/models.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

runtests.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
# python runtests.py [anymail.tests.test_x anymail.tests.test_y.SomeTestCase ...]
44

55
import sys
6+
7+
from django import setup
68
from django.conf import settings
9+
from django.test.runner import DiscoverRunner as TestRunner
10+
711

812
APP = 'anymail'
913

@@ -37,17 +41,8 @@
3741
],
3842
)
3943

40-
try:
41-
# Django 1.7+ initialize app registry
42-
from django import setup
43-
setup()
44-
except ImportError:
45-
pass
46-
47-
try:
48-
from django.test.runner import DiscoverRunner as TestRunner # Django 1.6+
49-
except ImportError:
50-
from django.test.simple import DjangoTestSuiteRunner as TestRunner # Django -1.5
44+
# Initialize Django app registry
45+
setup()
5146

5247

5348
def runtests(*args):

tests/__init__.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +0,0 @@
1-
# Exposing all TestCases at the 'tests' module level
2-
# is required by the old (<=1.5) DjangoTestSuiteRunner.
3-
4-
from .test_mailgun_backend import *
5-
from .test_mailgun_integration import *
6-
7-
from .test_mandrill_backend import *
8-
from .test_mandrill_integration import *
9-
10-
from .test_postmark_backend import *
11-
from .test_postmark_integration import *
12-
13-
from .test_sendgrid_backend import *
14-
from .test_sendgrid_webhooks import *
15-
from .test_sendgrid_integration import *
16-
17-
# Djrill leftovers:
18-
from .test_mandrill_djrill_features import *

tests/test_mailgun_backend.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,9 @@ def test_html_only_message(self):
111111
self.assertEqual(data['html'], html_content)
112112

113113
def test_reply_to(self):
114-
# reply_to is new in Django 1.8 -- before that, you can simply include it in headers
115-
try:
116-
# noinspection PyArgumentList
117-
email = mail.EmailMessage('Subject', 'Body goes here', '[email protected]', ['[email protected]'],
118-
reply_to=['[email protected]', 'Other <[email protected]>'],
119-
headers={'X-Other': 'Keep'})
120-
except TypeError:
121-
# Pre-Django 1.8
122-
return self.skipTest("Django version doesn't support EmailMessage(reply_to)")
114+
email = mail.EmailMessage('Subject', 'Body goes here', '[email protected]', ['[email protected]'],
115+
reply_to=['[email protected]', 'Other <[email protected]>'],
116+
headers={'X-Other': 'Keep'})
123117
email.send()
124118
data = self.get_api_call_data()
125119
self.assertEqual(data['h:Reply-To'], '[email protected], Other <[email protected]>')

tests/test_mandrill_backend.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,9 @@ def test_html_only_message(self):
132132
self.assertEqual(data['message']['html'], html_content)
133133

134134
def test_reply_to(self):
135-
# reply_to is new in Django 1.8 -- before that, you can simply include it in headers
136-
try:
137-
# noinspection PyArgumentList
138-
email = mail.EmailMessage('Subject', 'Body goes here', '[email protected]', ['[email protected]'],
139-
reply_to=['[email protected]', 'Other <[email protected]>'],
140-
headers={'X-Other': 'Keep'})
141-
except TypeError:
142-
# Pre-Django 1.8
143-
raise unittest.SkipTest("Django version doesn't support EmailMessage(reply_to)")
135+
email = mail.EmailMessage('Subject', 'Body goes here', '[email protected]', ['[email protected]'],
136+
reply_to=['[email protected]', 'Other <[email protected]>'],
137+
headers={'X-Other': 'Keep'})
144138
email.send()
145139
data = self.get_api_call_json()
146140
self.assertEqual(data['message']['headers']['Reply-To'],

tests/test_postmark_backend.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,9 @@ def test_extra_headers_serialization_error(self):
130130
self.message.send()
131131

132132
def test_reply_to(self):
133-
# reply_to is new in Django 1.8 -- before that, you can simply include it in headers
134-
try:
135-
# noinspection PyArgumentList
136-
email = mail.EmailMessage('Subject', 'Body goes here', '[email protected]', ['[email protected]'],
137-
reply_to=['[email protected]', 'Other <[email protected]>'],
138-
headers={'X-Other': 'Keep'})
139-
except TypeError:
140-
# Pre-Django 1.8
141-
return self.skipTest("Django version doesn't support EmailMessage(reply_to)")
133+
email = mail.EmailMessage('Subject', 'Body goes here', '[email protected]', ['[email protected]'],
134+
reply_to=['[email protected]', 'Other <[email protected]>'],
135+
headers={'X-Other': 'Keep'})
142136
email.send()
143137
data = self.get_api_call_json()
144138
self.assertEqual(data['ReplyTo'], '[email protected], Other <[email protected]>')

tests/test_sendgrid_backend.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,9 @@ def test_extra_headers_serialization_error(self):
169169
self.message.send()
170170

171171
def test_reply_to(self):
172-
# reply_to is new in Django 1.8 -- before that, you can simply include it in headers
173-
try:
174-
# noinspection PyArgumentList
175-
email = mail.EmailMessage('Subject', 'Body goes here', '[email protected]', ['[email protected]'],
176-
reply_to=['[email protected]', 'Other <[email protected]>'],
177-
headers={'X-Other': 'Keep'})
178-
except TypeError:
179-
# Pre-Django 1.8
180-
return self.skipTest("Django version doesn't support EmailMessage(reply_to)")
172+
email = mail.EmailMessage('Subject', 'Body goes here', '[email protected]', ['[email protected]'],
173+
reply_to=['[email protected]', 'Other <[email protected]>'],
174+
headers={'X-Other': 'Keep'})
181175
email.send()
182176
data = self.get_api_call_data()
183177
self.assertNotIn('replyto', data) # don't use SendGrid's replyto (it's broken); just use headers

0 commit comments

Comments
 (0)