mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
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:
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user