summaryrefslogtreecommitdiff
path: root/tests/test_utils
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_utils')
-rw-r--r--tests/test_utils/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index 0013452cac..54b83f524b 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -1069,6 +1069,18 @@ class DisallowedDatabaseQueriesTests(SimpleTestCase):
Car.objects.first()
+class DisallowedDatabaseQueriesChunkedCursorsTests(SimpleTestCase):
+ def test_disallowed_database_queries(self):
+ expected_message = (
+ "Database queries aren't allowed in SimpleTestCase. Either use "
+ "TestCase or TransactionTestCase to ensure proper test isolation or "
+ "set DisallowedDatabaseQueriesChunkedCursorsTests.allow_database_queries "
+ "to True to silence this failure."
+ )
+ with self.assertRaisesMessage(AssertionError, expected_message):
+ next(Car.objects.iterator())
+
+
class AllowedDatabaseQueriesTests(SimpleTestCase):
allow_database_queries = True