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
This commit is contained in:
Shai Berger 2015-06-05 10:32:29 +03:00
parent 1f28521e0a
commit 071801ccff
4 changed files with 15 additions and 28 deletions

View file

@ -370,10 +370,7 @@ class LastExecutedQueryTest(TestCase):
query has been run.
"""
cursor = connection.cursor()
try:
connection.ops.last_executed_query(cursor, '', ())
except Exception:
self.fail("'last_executed_query' should not raise an exception.")
connection.ops.last_executed_query(cursor, '', ())
def test_debug_sql(self):
list(models.Reporter.objects.filter(first_name="test"))