Be more careful about closing connections in mail tests.
This commit is contained in:
parent
9d2c5b0420
commit
22198e6ce5
|
@ -891,8 +891,11 @@ class SMTPBackendTests(BaseEmailBackendTests, SimpleTestCase):
|
||||||
"""
|
"""
|
||||||
backend = smtp.EmailBackend(
|
backend = smtp.EmailBackend(
|
||||||
username='not empty username', password='not empty password')
|
username='not empty username', password='not empty password')
|
||||||
self.assertRaisesMessage(SMTPException,
|
try:
|
||||||
'SMTP AUTH extension not supported by server.', backend.open)
|
self.assertRaisesMessage(SMTPException,
|
||||||
|
'SMTP AUTH extension not supported by server.', backend.open)
|
||||||
|
finally:
|
||||||
|
backend.close()
|
||||||
|
|
||||||
def test_server_open(self):
|
def test_server_open(self):
|
||||||
"""
|
"""
|
||||||
|
@ -949,14 +952,20 @@ class SMTPBackendTests(BaseEmailBackendTests, SimpleTestCase):
|
||||||
def test_email_tls_attempts_starttls(self):
|
def test_email_tls_attempts_starttls(self):
|
||||||
backend = smtp.EmailBackend()
|
backend = smtp.EmailBackend()
|
||||||
self.assertTrue(backend.use_tls)
|
self.assertTrue(backend.use_tls)
|
||||||
self.assertRaisesMessage(SMTPException,
|
try:
|
||||||
'STARTTLS extension not supported by server.', backend.open)
|
self.assertRaisesMessage(SMTPException,
|
||||||
|
'STARTTLS extension not supported by server.', backend.open)
|
||||||
|
finally:
|
||||||
|
backend.close()
|
||||||
|
|
||||||
@override_settings(EMAIL_USE_SSL=True)
|
@override_settings(EMAIL_USE_SSL=True)
|
||||||
def test_email_ssl_attempts_ssl_connection(self):
|
def test_email_ssl_attempts_ssl_connection(self):
|
||||||
backend = smtp.EmailBackend()
|
backend = smtp.EmailBackend()
|
||||||
self.assertTrue(backend.use_ssl)
|
self.assertTrue(backend.use_ssl)
|
||||||
self.assertRaises(SSLError, backend.open)
|
try:
|
||||||
|
self.assertRaises(SSLError, backend.open)
|
||||||
|
finally:
|
||||||
|
backend.close()
|
||||||
|
|
||||||
def test_connection_timeout_default(self):
|
def test_connection_timeout_default(self):
|
||||||
"""Test that the connection's timeout value is None by default."""
|
"""Test that the connection's timeout value is None by default."""
|
||||||
|
@ -974,3 +983,4 @@ class SMTPBackendTests(BaseEmailBackendTests, SimpleTestCase):
|
||||||
myemailbackend.open()
|
myemailbackend.open()
|
||||||
self.assertEqual(myemailbackend.timeout, 42)
|
self.assertEqual(myemailbackend.timeout, 42)
|
||||||
self.assertEqual(myemailbackend.connection.timeout, 42)
|
self.assertEqual(myemailbackend.connection.timeout, 42)
|
||||||
|
myemailbackend.close()
|
||||||
|
|
Loading…
Reference in New Issue