diff options
| author | Tim Graham <timograham@gmail.com> | 2016-06-28 11:21:26 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-07-01 09:58:56 -0400 |
| commit | 567cfc1601a5f475eea12bc5de53b849fa5dadea (patch) | |
| tree | c471ba1af748008e4fbe9faee8cf51d4dffcd263 /tests/raw_query/tests.py | |
| parent | 9c48e17480432b8723fcdcc262d8d62866e93a4f (diff) | |
[1.10.x] Replaced use of TestCase.fail() with assertRaises().
Also removed try/except/fail antipattern that hides exceptions.
Backport of c9ae09addffb839403312131d4251e9d8b454508 from master
Diffstat (limited to 'tests/raw_query/tests.py')
| -rw-r--r-- | tests/raw_query/tests.py | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/tests/raw_query/tests.py b/tests/raw_query/tests.py index f4fe90aeb6..4c791dd206 100644 --- a/tests/raw_query/tests.py +++ b/tests/raw_query/tests.py @@ -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): """ |
