aboutsummaryrefslogtreecommitdiff
path: root/tests/test_command.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_command.py')
-rw-r--r--tests/test_command.py44
1 files changed, 41 insertions, 3 deletions
diff --git a/tests/test_command.py b/tests/test_command.py
index 1d1402c..667fef6 100644
--- a/tests/test_command.py
+++ b/tests/test_command.py
@@ -155,8 +155,9 @@ class testCommand(hazwaz.unittest.HazwazTestCase):
stream = self.run_with_argv(cmd, ["mycommand"])
self.assertEqual(stream["stdout"].getvalue(), cmd_help)
- def test_logging_regular(self):
+ def test_logging_regular_coloredlogs(self):
cmd = MyCommand()
+ cmd.coloredlogs = True
with self.assertLogs():
stream = self.run_with_argv(cmd, [
"mycommand",
@@ -165,8 +166,9 @@ class testCommand(hazwaz.unittest.HazwazTestCase):
log_lines = stream["stderr"].getvalue().strip().split("\n")
self.assertEqual(len(log_lines), 1)
- def test_logging_verbose(self):
+ def test_logging_verbose_coloredlogs(self):
cmd = MyCommand()
+ cmd.coloredlogs = True
with self.assertLogs():
stream = self.run_with_argv(cmd, [
"mycommand",
@@ -176,8 +178,44 @@ class testCommand(hazwaz.unittest.HazwazTestCase):
log_lines = stream["stderr"].getvalue().strip().split("\n")
self.assertEqual(len(log_lines), 2)
- def test_logging_debug(self):
+ def test_logging_debug_coloredlogs(self):
cmd = MyCommand()
+ cmd.coloredlogs = True
+ with self.assertLogs():
+ stream = self.run_with_argv(cmd, [
+ "mycommand",
+ "--debug",
+ "loggingsubcommand",
+ ])
+ log_lines = stream["stderr"].getvalue().strip().split("\n")
+ self.assertEqual(len(log_lines), 3)
+
+ def test_logging_regular_no_coloredlogs(self):
+ cmd = MyCommand()
+ cmd.coloredlogs = False
+ with self.assertLogs():
+ stream = self.run_with_argv(cmd, [
+ "mycommand",
+ "loggingsubcommand",
+ ])
+ log_lines = stream["stderr"].getvalue().strip().split("\n")
+ self.assertEqual(len(log_lines), 1)
+
+ def test_logging_verbose_no_coloredlogs(self):
+ cmd = MyCommand()
+ cmd.coloredlogs = False
+ with self.assertLogs():
+ stream = self.run_with_argv(cmd, [
+ "mycommand",
+ "--verbose",
+ "loggingsubcommand",
+ ])
+ log_lines = stream["stderr"].getvalue().strip().split("\n")
+ self.assertEqual(len(log_lines), 2)
+
+ def test_logging_debug_no_coloredlogs(self):
+ cmd = MyCommand()
+ cmd.coloredlogs = False
with self.assertLogs():
stream = self.run_with_argv(cmd, [
"mycommand",