mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Used assertRaisesMessage() in various tests.
This commit is contained in:
committed by
Mariusz Felisiak
parent
71756bdfed
commit
fc4f45ebdc
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user