mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Thanks Akshesh Doshi for the initial patch and Tim Graham for the review
This commit is contained in:
@@ -9,6 +9,7 @@ from admin_scripts.tests import AdminScriptTestCase
|
||||
from django.conf import settings
|
||||
from django.core import mail
|
||||
from django.core.files.temp import NamedTemporaryFile
|
||||
from django.db import connection
|
||||
from django.test import RequestFactory, SimpleTestCase, override_settings
|
||||
from django.test.utils import LoggingCaptureMixin, patch_logger
|
||||
from django.utils.deprecation import RemovedInNextVersionWarning
|
||||
@@ -475,3 +476,23 @@ format=%(message)s
|
||||
out, err = self.run_manage(['check'])
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "System check identified no issues (0 silenced).")
|
||||
|
||||
|
||||
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': 'SELECT * FROM foo WHERE id in (%s, %s)',
|
||||
'params': [42, 1337],
|
||||
}},
|
||||
)]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user