From 19598b68106333d44a91aa6f62590232dff443ed Mon Sep 17 00:00:00 2001 From: Bambu <564972+bambu@users.noreply.github.com> Date: Fri, 9 Oct 2020 23:27:02 -0400 Subject: Format multiline docstrings to match other help messages Changed cmd2 do_cmd to dedent docstrings using `pydoc.getdoc`. This patch provides output for docstrings that look like using argparse or a single line docstring --- tests/test_cmd2.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 034f7096..554f2ba7 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -981,6 +981,16 @@ class HelpApp(cmd2.Cmd): def do_undoc(self, arg): pass + def do_multiline_docstr(self, arg): + """ + This documentation + is multiple lines + and there are no + tabs + """ + pass + + @pytest.fixture def help_app(): app = HelpApp() @@ -1004,6 +1014,11 @@ def test_help_overridden_method(help_app): expected = normalize('This overrides the edit command and does nothing.') assert out == expected +def test_help_multiline_docstring(help_app): + out, err = run_cmd(help_app, 'help multiline_docstr') + expected = normalize('This documentation\nis multiple lines\nand there are no\ntabs') + assert out == expected + class HelpCategoriesApp(cmd2.Cmd): """Class for testing custom help_* methods which override docstring help.""" -- cgit v1.2.1