From 5ce5f10bad44b997b6e4b4da327e60e7e3637ea5 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Fri, 11 Mar 2022 18:40:10 +0100 Subject: Docstrings --- tests/test_command.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') 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() -- cgit v1.2.3