diff options
| author | levental <levental@fh-brandenburg.de> | 2016-09-20 19:34:01 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-09-21 16:45:10 -0400 |
| commit | 42dc9d04006c0bdecba6e0c8a29038b01d5a62d7 (patch) | |
| tree | 6bcf2e0e007d43b7db4ce34cc996d2f087024676 /tests/mail | |
| parent | 2b8ccff3b6278f862a2d4840f55a7062747a452f (diff) | |
Fixed #26210 -- Prevented SMTP backend from trying to send mail after a connection failure.
Diffstat (limited to 'tests/mail')
| -rw-r--r-- | tests/mail/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/mail/tests.py b/tests/mail/tests.py index 93e2127d63..e518ca46d5 100644 --- a/tests/mail/tests.py +++ b/tests/mail/tests.py @@ -1448,6 +1448,19 @@ class SMTPBackendTests(BaseEmailBackendTests, SMTPBackendTestsBase): finally: SMTP.send = send + def test_send_messages_after_open_failed(self): + """ + send_messages() shouldn't try to send messages if open() raises an + exception after initializing the connection. + """ + backend = smtp.EmailBackend() + # Simulate connection initialization success and a subsequent + # connection exception. + backend.connection = True + backend.open = lambda: None + email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com']) + self.assertEqual(backend.send_messages([email]), None) + class SMTPBackendStoppedServerTest(SMTPBackendTestsBase): """ |
