diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2020-02-04 21:58:07 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-02-07 12:46:23 +0100 |
| commit | fc4f45ebdccd87f140f39bebed897053c7f345c5 (patch) | |
| tree | 0080670fe0c04124b7b2e15766fac2d73a00f164 /tests/test_utils | |
| parent | 71756bdfed5029bd14dce8cb3c5629efc4be55ac (diff) | |
Used assertRaisesMessage() in various tests.
Diffstat (limited to 'tests/test_utils')
| -rw-r--r-- | tests/test_utils/tests.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index c61358f4c8..8d7e6e4889 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -374,13 +374,13 @@ class AssertNumQueriesContextManagerTests(TestCase): Person.objects.count() def test_failure(self): - with self.assertRaises(AssertionError) as exc_info: + msg = ( + '1 != 2 : 1 queries executed, 2 expected\nCaptured queries were:\n' + '1.' + ) + with self.assertRaisesMessage(AssertionError, msg): with self.assertNumQueries(2): Person.objects.count() - exc_lines = str(exc_info.exception).split('\n') - self.assertEqual(exc_lines[0], '1 != 2 : 1 queries executed, 2 expected') - self.assertEqual(exc_lines[1], 'Captured queries were:') - self.assertTrue(exc_lines[2].startswith('1.')) # queries are numbered with self.assertRaises(TypeError): with self.assertNumQueries(4000): |
