summaryrefslogtreecommitdiff
path: root/tests/schema
diff options
context:
space:
mode:
Diffstat (limited to 'tests/schema')
-rw-r--r--tests/schema/test_logging.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/schema/test_logging.py b/tests/schema/test_logging.py
new file mode 100644
index 0000000000..8c7313abb1
--- /dev/null
+++ b/tests/schema/test_logging.py
@@ -0,0 +1,20 @@
+from django.db import connection
+from django.test import SimpleTestCase
+from django.test.utils import patch_logger
+
+
+class SchemaLoggerTests(SimpleTestCase):
+
+ def test_extra_args(self):
+ editor = connection.schema_editor(collect_sql=True)
+ sql = 'SELECT * FROM foo WHERE id in (%s, %s)'
+ params = [42, 1337]
+ with patch_logger('django.db.backends.schema', 'debug', log_kwargs=True) as logger:
+ editor.execute(sql, params)
+ self.assertEqual(
+ logger,
+ [(
+ 'SELECT * FROM foo WHERE id in (%s, %s); (params [42, 1337])',
+ {'extra': {'sql': sql, 'params': params}},
+ )]
+ )