diff options
-rw-r--r-- | tests/test_command.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/tests/test_command.py b/tests/test_command.py index cc64b8f..cbb7aad 100644 --- a/tests/test_command.py +++ b/tests/test_command.py @@ -173,32 +173,35 @@ class testCommand(unittest.TestCase): def test_logging_regular(self): cmd = MyCommand() - with self.assertLogs() as cm: - self._run_with_argv(cmd, [ + with self.assertLogs(): + stream = self._run_with_argv(cmd, [ "mycommand", "loggingsubcommand", ]) - self.assertEqual(len(cm.output), 1) + log_lines = stream["stderr"].getvalue().strip().split("\n") + self.assertEqual(len(log_lines), 1) def test_logging_verbose(self): cmd = MyCommand() - with self.assertLogs() as cm: - self._run_with_argv(cmd, [ + with self.assertLogs(): + stream = self._run_with_argv(cmd, [ "mycommand", "--verbose", "loggingsubcommand", ]) - self.assertEqual(len(cm.output), 2) + log_lines = stream["stderr"].getvalue().strip().split("\n") + self.assertEqual(len(log_lines), 2) def test_logging_debug(self): cmd = MyCommand() - with self.assertLogs() as cm: - self._run_with_argv(cmd, [ + with self.assertLogs(): + stream = self._run_with_argv(cmd, [ "mycommand", "--debug", "loggingsubcommand", ]) - self.assertEqual(len(cm.output), 3) + log_lines = stream["stderr"].getvalue().strip().split("\n") + self.assertEqual(len(log_lines), 3) if __name__ == '__main__': |