Kaydet (Commit) 9d2c5b04 authored tarafından Marc Tamlyn's avatar Marc Tamlyn

Undelete the `return True` removed in 4e0a2fe5.

This is quite important otherwise we don't close our connections to the
SMTP server.
üst 89f12c05
...@@ -57,6 +57,7 @@ class EmailBackend(BaseEmailBackend): ...@@ -57,6 +57,7 @@ class EmailBackend(BaseEmailBackend):
self.connection.ehlo() self.connection.ehlo()
if self.username and self.password: if self.username and self.password:
self.connection.login(self.username, self.password) self.connection.login(self.username, self.password)
return True
except smtplib.SMTPException: except smtplib.SMTPException:
if not self.fail_silently: if not self.fail_silently:
raise raise
......
...@@ -894,6 +894,16 @@ class SMTPBackendTests(BaseEmailBackendTests, SimpleTestCase): ...@@ -894,6 +894,16 @@ class SMTPBackendTests(BaseEmailBackendTests, SimpleTestCase):
self.assertRaisesMessage(SMTPException, self.assertRaisesMessage(SMTPException,
'SMTP AUTH extension not supported by server.', backend.open) 'SMTP AUTH extension not supported by server.', backend.open)
def test_server_open(self):
"""
Test that open() tells us whether it opened a connection.
"""
backend = smtp.EmailBackend(username='', password='')
self.assertFalse(backend.connection)
opened = backend.open()
backend.close()
self.assertTrue(opened)
def test_server_stopped(self): def test_server_stopped(self):
""" """
Test that closing the backend while the SMTP server is stopped doesn't Test that closing the backend while the SMTP server is stopped doesn't
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment