From 071801ccff970682a799ce754431a3c3ce3d6902 Mon Sep 17 00:00:00 2001 From: Shai Berger Date: Fri, 5 Jun 2015 10:32:29 +0300 Subject: Cleanup: Removed the try-except-fail antipattern from tests Found cases where testing code was doing try: whatever except (some excption type): self.fail("exception shouldn't be thrown") replaced it with just whatever as this makes the unexpected errors easier to debug, and the tests would fail just as much and aren't rendered less readable. Thanks Markus Holtermann for review --- tests/mail/tests.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'tests/mail') diff --git a/tests/mail/tests.py b/tests/mail/tests.py index 03dfae7903..f6eff3bb8f 100644 --- a/tests/mail/tests.py +++ b/tests/mail/tests.py @@ -695,10 +695,7 @@ class BaseEmailBackendTests(HeadersCheckMixin, object): Test that connection can be closed (even when not explicitly opened) """ conn = mail.get_connection(username='', password='') - try: - conn.close() - except Exception as e: - self.fail("close() unexpectedly raised an exception: %s" % e) + conn.close() def test_use_as_contextmanager(self): """ @@ -1146,7 +1143,4 @@ class SMTPBackendStoppedServerTest(SMTPBackendTestsBase): 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) + backend.close() -- cgit v1.3