mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Moved SchemaLoggingTest to tests/schema.
This commit is contained in:
parent
feb683c4c2
commit
fb8fd535c0
@ -8,7 +8,6 @@ from django.conf import settings
|
||||
from django.core import mail
|
||||
from django.core.files.temp import NamedTemporaryFile
|
||||
from django.core.management import color
|
||||
from django.db import connection
|
||||
from django.test import RequestFactory, SimpleTestCase, override_settings
|
||||
from django.test.utils import LoggingCaptureMixin, patch_logger
|
||||
from django.utils.log import (
|
||||
@ -463,26 +462,6 @@ format=%(message)s
|
||||
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],
|
||||
}},
|
||||
)]
|
||||
)
|
||||
|
||||
|
||||
class LogFormattersTests(SimpleTestCase):
|
||||
|
||||
def test_server_formatter_styles(self):
|
||||
|
20
tests/schema/test_logging.py
Normal file
20
tests/schema/test_logging.py
Normal file
@ -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}},
|
||||
)]
|
||||
)
|
Loading…
Reference in New Issue
Block a user