Ticket #24623: 24623-test.diff

File 24623-test.diff, 1.2 KB (added by Tim Graham, 10 years ago)
  • tests/mail/tests.py

    diff --git a/tests/mail/file.txt b/tests/mail/file.txt
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/mail/tests.py b/tests/mail/tests.py
    index 75d5dd6..3b6c2d3 100644
    a b from django.core.mail import (  
    2020from django.core.mail.backends import console, dummy, filebased, locmem, smtp
    2121from django.core.mail.message import BadHeaderError
    2222from django.test import SimpleTestCase, override_settings
     23from django.utils._os import upath
    2324from django.utils.encoding import force_bytes, force_text
    2425from django.utils.six import PY3, StringIO, binary_type
    2526from django.utils.translation import ugettext_lazy
    class MailTests(HeadersCheckMixin, SimpleTestCase):  
    305306        payload = message.get_payload()
    306307        self.assertEqual(payload[1].get_filename(), 'une pièce jointe.pdf')
    307308
     309    def test_attach_file(self):
     310        email = EmailMessage('subject', 'body', 'from@example.com', ['to@example.com'])
     311        email.attach_file(os.path.join(os.path.dirname(upath(__file__)), 'file.txt'))
     312        email.send()
     313
    308314    def test_dummy_backend(self):
    309315        """
    310316        Make sure that dummy backends returns correct number of sent messages
Back to Top