Ticket #18861: 18861-2.diff

File 18861-2.diff, 1.3 KB (added by Claude Paroz, 12 years ago)

Move test in LocmemBackendTests

  • django/core/mail/backends/locmem.py

    diff --git a/django/core/mail/backends/locmem.py b/django/core/mail/backends/locmem.py
    index 642bfc4..6826d09 100644
    a b class EmailBackend(BaseEmailBackend):  
    2020
    2121    def send_messages(self, messages):
    2222        """Redirect messages to the dummy outbox"""
     23        for message in messages:  # .message() triggers header validation
     24            message.message()
    2325        mail.outbox.extend(messages)
    2426        return len(messages)
  • tests/regressiontests/mail/tests.py

    diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py
    index 3e9ae84..33898cc 100644
    a b class LocmemBackendTests(BaseEmailBackendTests, TestCase):  
    498498        connection2.send_messages([email])
    499499        self.assertEqual(len(mail.outbox), 2)
    500500
     501    def test_validate_multiline_headers(self):
     502        # Ticket #18861 - Validate emails when using the locmem backend
     503        with self.assertRaises(BadHeaderError):
     504            send_mail('Subject\nMultiline', 'Content', 'from@example.com', ['to@example.com'])
     505
    501506
    502507class FileBackendTests(BaseEmailBackendTests, TestCase):
    503508    email_backend = 'django.core.mail.backends.filebased.EmailBackend'
Back to Top