#23003: Implement an EmailBackend raising an smtplib.SMTPException on
send_messages()
-------------------------------------+-------------------------------------
     Reporter:  brgl                 |                    Owner:  brgl
         Type:  New feature          |                   Status:  closed
    Component:  Core (Mail)          |                  Version:  master
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:  mail emailbackend    |             Triage Stage:
  smtpexception                      |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by charettes):

 * status:  assigned => closed
 * resolution:   => wontfix


Comment:

 @brgl, I agree with Tim that this doesn't need to be included in Django.

 I suggest you take a look at the `mock` library for such use cases. It's
 part of the standard library since Python3.3 (in the `unittest` package)
 and available as standalone package on pypi for Python3.2-.


 {{{#!python
 from smtplib import SMTPException
 try:
     from unittest import mock  # Python 3.3+
 except ImportError:
     try:
         import mock  # Python 3.2-
     except ImportError:
         raise ImportError(
             'Make sure to install the `mock` package on Python 3.2-.'
         )

 from django.conf import settings
 from django.test import TestCase


 class SMTPExceptionHandlingTests(TestCase):
     def test_handling(self):
         send_messages = "%s.%s" % (settings.EMAIL_BACKEND,
 'send_messages')
         with mock.patch(send_messages, side_effect=SMTPException):
             # Assert exception is correctly handled in this context
 below...

 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/23003#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/062.9705ef5685779ebb9dbe733f89794dab%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to