summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-01-03 18:49:00 +0100
committerClaude Paroz <claude@2xlibre.net>2013-01-03 20:45:29 +0100
commit4081042ef51c0e679c78f2d0d13514af3434ed13 (patch)
tree76b436021277371ba690624221f7eee421e00bfb /tests/regressiontests
parenta893ee3315d6a134b46ff8c36c44a8efbbe34886 (diff)
[1.5.x] Fixed #19134 -- Allowed closing smtp backend when the server is stopped
Thanks Sebastian Noack for the report and the initial patch. Backport of 1b3f832ab7 from master.
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/mail/tests.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py
index a8fbf20fd6..9ab8c2c301 100644
--- a/tests/regressiontests/mail/tests.py
+++ b/tests/regressiontests/mail/tests.py
@@ -659,9 +659,9 @@ class FakeSMTPServer(smtpd.SMTPServer, threading.Thread):
asyncore.close_all()
def stop(self):
- assert self.active
- self.active = False
- self.join()
+ if self.active:
+ self.active = False
+ self.join()
class SMTPBackendTests(BaseEmailBackendTests, TestCase):
@@ -715,3 +715,16 @@ class SMTPBackendTests(BaseEmailBackendTests, TestCase):
backend = smtp.EmailBackend(username='', password='')
self.assertEqual(backend.username, '')
self.assertEqual(backend.password, '')
+
+ def test_server_stopped(self):
+ """
+ Test that closing the backend while the SMTP server is stopped doesn't
+ raise an exception.
+ """
+ backend = smtp.EmailBackend(username='', password='')
+ backend.open()
+ self.server.stop()
+ try:
+ backend.close()
+ except Exception as e:
+ self.fail("close() unexpectedly raised an exception: %s" % e)