mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +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:
parent
1f28521e0a
commit
071801ccff
4 changed files with 15 additions and 28 deletions
|
@ -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"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue