diff options
| author | Claude Paroz <claude@2xlibre.net> | 2018-04-28 15:20:27 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-05-07 09:34:00 -0400 |
| commit | 607970f31cc07c317f2ebb684c8f3ccc36a95b3e (patch) | |
| tree | b11c0976fb161d3339025400b048a27ce5e2f19f /tests/schema/test_logging.py | |
| parent | 7d3fe36c626a3268413eb86d37920f132eb4a54f (diff) | |
Replaced django.test.utils.patch_logger() with assertLogs().
Thanks Tim Graham for the review.
Diffstat (limited to 'tests/schema/test_logging.py')
| -rw-r--r-- | tests/schema/test_logging.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/tests/schema/test_logging.py b/tests/schema/test_logging.py index 21e3c9e4a6..453bdd798e 100644 --- a/tests/schema/test_logging.py +++ b/tests/schema/test_logging.py @@ -1,6 +1,5 @@ from django.db import connection from django.test import TestCase -from django.test.utils import patch_logger class SchemaLoggerTests(TestCase): @@ -9,12 +8,11 @@ class SchemaLoggerTests(TestCase): 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: + with self.assertLogs('django.db.backends.schema', 'DEBUG') as cm: editor.execute(sql, params) + self.assertEqual(cm.records[0].sql, sql) + self.assertEqual(cm.records[0].params, params) self.assertEqual( - logger, - [( - 'SELECT * FROM foo WHERE id in (%s, %s); (params [42, 1337])', - {'extra': {'sql': sql, 'params': params}}, - )] + cm.records[0].getMessage(), + 'SELECT * FROM foo WHERE id in (%s, %s); (params [42, 1337])', ) |
