summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2022-03-11 18:40:10 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2022-03-11 18:40:10 +0100
commit5ce5f10bad44b997b6e4b4da327e60e7e3637ea5 (patch)
treee197b4f885e3797ea07ef68ccf017957019cd80a /tests
parent31ca1192969251904917b27ba085bbe1adc8a5d1 (diff)
Docstrings
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()