mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #23620 -- Used more specific assertions in the Django test suite.
This commit is contained in:
committed by
Tim Graham
parent
c0c78f1b70
commit
f7969b0920
@@ -346,31 +346,31 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
|
||||
# Regression for #13433 - Make sure that EmailMessage doesn't mangle
|
||||
# 'From ' in message body.
|
||||
email = EmailMessage('Subject', 'From the future', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'})
|
||||
self.assertFalse(b'>From the future' in email.message().as_bytes())
|
||||
self.assertNotIn(b'>From the future', email.message().as_bytes())
|
||||
|
||||
def test_dont_base64_encode(self):
|
||||
# Ticket #3472
|
||||
# Shouldn't use Base64 encoding at all
|
||||
msg = EmailMessage('Subject', 'UTF-8 encoded body', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'})
|
||||
self.assertFalse(b'Content-Transfer-Encoding: base64' in msg.message().as_bytes())
|
||||
self.assertNotIn(b'Content-Transfer-Encoding: base64', msg.message().as_bytes())
|
||||
|
||||
# Ticket #11212
|
||||
# Shouldn't use quoted printable, should detect it can represent content with 7 bit data
|
||||
msg = EmailMessage('Subject', 'Body with only ASCII characters.', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'})
|
||||
s = msg.message().as_bytes()
|
||||
self.assertFalse(b'Content-Transfer-Encoding: quoted-printable' in s)
|
||||
self.assertTrue(b'Content-Transfer-Encoding: 7bit' in s)
|
||||
self.assertNotIn(b'Content-Transfer-Encoding: quoted-printable', s)
|
||||
self.assertIn(b'Content-Transfer-Encoding: 7bit', s)
|
||||
|
||||
# Shouldn't use quoted printable, should detect it can represent content with 8 bit data
|
||||
msg = EmailMessage('Subject', 'Body with latin characters: àáä.', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'})
|
||||
s = msg.message().as_bytes()
|
||||
self.assertFalse(b'Content-Transfer-Encoding: quoted-printable' in s)
|
||||
self.assertTrue(b'Content-Transfer-Encoding: 8bit' in s)
|
||||
self.assertNotIn(b'Content-Transfer-Encoding: quoted-printable', s)
|
||||
self.assertIn(b'Content-Transfer-Encoding: 8bit', s)
|
||||
|
||||
msg = EmailMessage('Subject', 'Body with non latin characters: А Б В Г Д Е Ж Ѕ З И І К Л М Н О П.', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'})
|
||||
s = msg.message().as_bytes()
|
||||
self.assertFalse(b'Content-Transfer-Encoding: quoted-printable' in s)
|
||||
self.assertTrue(b'Content-Transfer-Encoding: 8bit' in s)
|
||||
self.assertNotIn(b'Content-Transfer-Encoding: quoted-printable', s)
|
||||
self.assertIn(b'Content-Transfer-Encoding: 8bit', s)
|
||||
|
||||
def test_dont_base64_encode_message_rfc822(self):
|
||||
# Ticket #18967
|
||||
@@ -387,7 +387,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
|
||||
parent_s = parent_msg.message().as_string()
|
||||
|
||||
# Verify that the child message header is not base64 encoded
|
||||
self.assertTrue(str('Child Subject') in parent_s)
|
||||
self.assertIn(str('Child Subject'), parent_s)
|
||||
|
||||
# Feature test: try attaching email.Message object directly to the mail.
|
||||
parent_msg = EmailMessage('Parent Subject', 'Some parent body', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'})
|
||||
@@ -395,7 +395,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
|
||||
parent_s = parent_msg.message().as_string()
|
||||
|
||||
# Verify that the child message header is not base64 encoded
|
||||
self.assertTrue(str('Child Subject') in parent_s)
|
||||
self.assertIn(str('Child Subject'), parent_s)
|
||||
|
||||
# Feature test: try attaching Django's EmailMessage object directly to the mail.
|
||||
parent_msg = EmailMessage('Parent Subject', 'Some parent body', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'})
|
||||
@@ -403,7 +403,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
|
||||
parent_s = parent_msg.message().as_string()
|
||||
|
||||
# Verify that the child message header is not base64 encoded
|
||||
self.assertTrue(str('Child Subject') in parent_s)
|
||||
self.assertIn(str('Child Subject'), parent_s)
|
||||
|
||||
|
||||
class PythonGlobalState(SimpleTestCase):
|
||||
@@ -415,19 +415,19 @@ class PythonGlobalState(SimpleTestCase):
|
||||
|
||||
def test_utf8(self):
|
||||
txt = MIMEText('UTF-8 encoded body', 'plain', 'utf-8')
|
||||
self.assertTrue('Content-Transfer-Encoding: base64' in txt.as_string())
|
||||
self.assertIn('Content-Transfer-Encoding: base64', txt.as_string())
|
||||
|
||||
def test_7bit(self):
|
||||
txt = MIMEText('Body with only ASCII characters.', 'plain', 'utf-8')
|
||||
self.assertTrue('Content-Transfer-Encoding: base64' in txt.as_string())
|
||||
self.assertIn('Content-Transfer-Encoding: base64', txt.as_string())
|
||||
|
||||
def test_8bit_latin(self):
|
||||
txt = MIMEText('Body with latin characters: àáä.', 'plain', 'utf-8')
|
||||
self.assertTrue(str('Content-Transfer-Encoding: base64') in txt.as_string())
|
||||
self.assertIn(str('Content-Transfer-Encoding: base64'), txt.as_string())
|
||||
|
||||
def test_8bit_non_latin(self):
|
||||
txt = MIMEText('Body with non latin characters: А Б В Г Д Е Ж Ѕ З И І К Л М Н О П.', 'plain', 'utf-8')
|
||||
self.assertTrue(str('Content-Transfer-Encoding: base64') in txt.as_string())
|
||||
self.assertIn(str('Content-Transfer-Encoding: base64'), txt.as_string())
|
||||
|
||||
|
||||
class BaseEmailBackendTests(HeadersCheckMixin, object):
|
||||
|
||||
Reference in New Issue
Block a user