summaryrefslogtreecommitdiff
path: root/tests/backends
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2025-01-04 20:27:28 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2025-01-18 07:04:57 +0100
commitd8f093908c504ae0dbc39d3f5231f7d7920dde37 (patch)
tree5ac3621f397a55f25fdb0624ece4a67c385baf67 /tests/backends
parent98767ba2eceafa0de10c561d051d54e340c2d29b (diff)
Fixed #35448 -- Fixed formatting of test --debug-sql output.
Also adds DatabaseOperations.format_debug_sql() hook for backends (e.g. NoSQL) to customize formatting.
Diffstat (limited to 'tests/backends')
-rw-r--r--tests/backends/tests.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/backends/tests.py b/tests/backends/tests.py
index 2adfa51360..a7fd7a9bcf 100644
--- a/tests/backends/tests.py
+++ b/tests/backends/tests.py
@@ -77,7 +77,12 @@ class LastExecutedQueryTest(TestCase):
connection.ops.last_executed_query(cursor, "", ())
def test_debug_sql(self):
- list(Reporter.objects.filter(first_name="test"))
+ qs = Reporter.objects.filter(first_name="test")
+ ops = connections[qs.db].ops
+ with mock.patch.object(ops, "format_debug_sql") as format_debug_sql:
+ list(qs)
+ # Queries are formatted with DatabaseOperations.format_debug_sql().
+ format_debug_sql.assert_called()
sql = connection.queries[-1]["sql"].lower()
self.assertIn("select", sql)
self.assertIn(Reporter._meta.db_table, sql)