mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Replaced use of TestCase.fail() with assertRaises().
Also removed try/except/fail antipattern that hides exceptions.
This commit is contained in:
@@ -221,11 +221,8 @@ class RawQueryTests(TestCase):
|
||||
|
||||
def test_missing_fields_without_PK(self):
|
||||
query = "SELECT first_name, dob FROM raw_query_author"
|
||||
try:
|
||||
with self.assertRaisesMessage(InvalidQuery, 'Raw query must include the primary key'):
|
||||
list(Author.objects.raw(query))
|
||||
self.fail('Query without primary key should fail')
|
||||
except InvalidQuery:
|
||||
pass
|
||||
|
||||
def test_annotations(self):
|
||||
query = (
|
||||
@@ -290,10 +287,7 @@ class RawQueryTests(TestCase):
|
||||
self.assertNumQueries(1, list, Author.objects.raw("SELECT * FROM raw_query_author"))
|
||||
|
||||
def test_subquery_in_raw_sql(self):
|
||||
try:
|
||||
list(Book.objects.raw('SELECT id FROM (SELECT * FROM raw_query_book WHERE paperback IS NOT NULL) sq'))
|
||||
except InvalidQuery:
|
||||
self.fail("Using a subquery in a RawQuerySet raised InvalidQuery")
|
||||
list(Book.objects.raw('SELECT id FROM (SELECT * FROM raw_query_book WHERE paperback IS NOT NULL) sq'))
|
||||
|
||||
def test_db_column_name_is_used_in_raw_query(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user