diff options
| author | Tim Graham <timograham@gmail.com> | 2025-01-04 20:27:28 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2025-01-18 07:04:57 +0100 |
| commit | d8f093908c504ae0dbc39d3f5231f7d7920dde37 (patch) | |
| tree | 5ac3621f397a55f25fdb0624ece4a67c385baf67 /tests/backends | |
| parent | 98767ba2eceafa0de10c561d051d54e340c2d29b (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.py | 7 |
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) |
