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/shell | |
parent | 7d3fe36c626a3268413eb86d37920f132eb4a54f (diff) | |
download | django-607970f31cc07c317f2ebb684c8f3ccc36a95b3e.tar.gz |
Replaced django.test.utils.patch_logger() with assertLogs().
Thanks Tim Graham for the review.
Diffstat (limited to 'tests/shell')
-rw-r--r-- | tests/shell/tests.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/tests/shell/tests.py b/tests/shell/tests.py index 6d39af3a71..f33a9ae701 100644 --- a/tests/shell/tests.py +++ b/tests/shell/tests.py @@ -5,13 +5,13 @@ from unittest import mock from django import __version__ from django.core.management import CommandError, call_command from django.test import SimpleTestCase -from django.test.utils import captured_stdin, captured_stdout, patch_logger +from django.test.utils import captured_stdin, captured_stdout class ShellCommandTestCase(SimpleTestCase): def test_command_option(self): - with patch_logger('test', 'info') as logger: + with self.assertLogs('test', 'INFO') as cm: call_command( 'shell', command=( @@ -19,8 +19,7 @@ class ShellCommandTestCase(SimpleTestCase): 'getLogger("test").info(django.__version__)' ), ) - self.assertEqual(len(logger), 1) - self.assertEqual(logger[0], __version__) + self.assertEqual(cm.records[0].getMessage(), __version__) @unittest.skipIf(sys.platform == 'win32', "Windows select() doesn't support file descriptors.") @mock.patch('django.core.management.commands.shell.select') |