aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_command.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_command.py b/tests/test_command.py
index f4e93bb..2f9850d 100644
--- a/tests/test_command.py
+++ b/tests/test_command.py
@@ -44,6 +44,25 @@ class MyCommand(hazwaz.MainCommand):
)
+class MyCommandWithNoVerbose(hazwaz.MainCommand):
+ """
+ A command that always talks.
+
+ This command doesn't have the --verbose and --debug arguments.
+
+ """
+
+ def add_arguments(self, parser):
+ # we override add_arguments and don't call
+ # super().add_arguments(parser) so that --verbose and --debug
+ # are missing.
+ parser.add_argument(
+ "--foo",
+ action="store_true",
+ help="foobar things",
+ )
+
+
class testCommand(unittest.TestCase):
def _run_with_argv(self, cmd, argv):
stream = {
@@ -133,6 +152,12 @@ class testCommand(unittest.TestCase):
])
self.assertEqual(stream["stdout"].getvalue(), "Hello World\n")
+ def test_run_no_verbose(self):
+ cmd = MyCommandWithNoVerbose()
+ cmd_help = cmd.parser.format_help()
+ stream = self._run_with_argv(cmd, ["mycommand"])
+ self.assertEqual(stream["stdout"].getvalue(), cmd_help)
+
if __name__ == '__main__':
unittest.main()