From 607970f31cc07c317f2ebb684c8f3ccc36a95b3e Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 28 Apr 2018 15:20:27 +0200 Subject: Replaced django.test.utils.patch_logger() with assertLogs(). Thanks Tim Graham for the review. --- tests/shell/tests.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tests/shell/tests.py') 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') -- cgit v1.3