summaryrefslogtreecommitdiff
path: root/tests/test_utils
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_utils')
-rw-r--r--tests/test_utils/tests.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index ae123920e0..e468c24727 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -435,6 +435,14 @@ class CaptureQueriesContextManagerTests(TestCase):
self.assertIn(self.person_pk, captured_queries[0]["sql"])
self.assertIn(self.person_pk, captured_queries[1]["sql"])
+ def test_with_client_nested(self):
+ with CaptureQueriesContext(connection) as captured_queries:
+ Person.objects.count()
+ with CaptureQueriesContext(connection):
+ pass
+ self.client.get(self.url)
+ self.assertEqual(2, len(captured_queries))
+
@override_settings(ROOT_URLCONF="test_utils.urls")
class AssertNumQueriesContextManagerTests(TestCase):
@@ -475,6 +483,13 @@ class AssertNumQueriesContextManagerTests(TestCase):
self.client.get(self.url)
self.client.get(self.url)
+ def test_with_client_nested(self):
+ with self.assertNumQueries(2):
+ Person.objects.count()
+ with self.assertNumQueries(0):
+ pass
+ self.client.get(self.url)
+
@override_settings(ROOT_URLCONF="test_utils.urls")
class AssertTemplateUsedContextManagerTests(SimpleTestCase):