summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2020-11-11 21:50:44 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2020-11-11 21:50:44 -0500
commitf02cf54284c4feacee5647d29665158fa5137f5f (patch)
treee421ec9b49338a312c0db759d4b5c87c7299e1a7 /tests/test_cmd2.py
parent0f11ffa3b992e3f777b96dfe46d4274bfca0dcc8 (diff)
parentd4dc6b6a98fdb44b08701a3826ee88b6c22b72fd (diff)
downloadcmd2-git-f02cf54284c4feacee5647d29665158fa5137f5f.tar.gz
Merge branch 'master' into 2.0
# Conflicts: # CHANGELOG.md
Diffstat (limited to 'tests/test_cmd2.py')
-rwxr-xr-xtests/test_cmd2.py38
1 files changed, 28 insertions, 10 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index d913b4fc..a8f2f993 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."""
@@ -1675,16 +1690,17 @@ def test_alias_create(base_app):
out, err = run_cmd(base_app, 'alias list --with_silent fake')
assert out == normalize('alias create --silent fake set')
-def test_alias_create_with_quoted_value(base_app):
- """Demonstrate that quotes in alias value will be preserved (except for redirectors and terminators)"""
+def test_alias_create_with_quoted_tokens(base_app):
+ """Demonstrate that quotes in alias value will be preserved"""
+ create_command = 'alias create fake help ">" "out file.txt" ";"'
# Create the alias
- out, err = run_cmd(base_app, 'alias create fake help ">" "out file.txt" ";"')
+ out, err = run_cmd(base_app, create_command)
assert out == normalize("Alias 'fake' created")
- # Look up the new alias (Only the redirector should be unquoted)
+ # Look up the new alias and verify all quotes are preserved
out, err = run_cmd(base_app, 'alias list fake')
- assert out == normalize('alias create fake help > "out file.txt" ;')
+ assert out == normalize(create_command)
@pytest.mark.parametrize('alias_name', invalid_command_name)
def test_alias_create_invalid_name(base_app, alias_name, capsys):
@@ -1784,15 +1800,17 @@ def test_macro_create(base_app):
out, err = run_cmd(base_app, 'macro list --with_silent fake')
assert out == normalize('macro create --silent fake set')
-def test_macro_create_with_quoted_value(base_app):
- """Demonstrate that quotes in macro value will be preserved (except for redirectors and terminators)"""
+def test_macro_create_with_quoted_tokens(base_app):
+ """Demonstrate that quotes in macro value will be preserved"""
+ create_command = 'macro create fake help ">" "out file.txt" ";"'
+
# Create the macro
- out, err = run_cmd(base_app, 'macro create fake help ">" "out file.txt" ";"')
+ out, err = run_cmd(base_app, create_command)
assert out == normalize("Macro 'fake' created")
- # Look up the new macro (Only the redirector should be unquoted)
+ # Look up the new macro and verify all quotes are preserved
out, err = run_cmd(base_app, 'macro list fake')
- assert out == normalize('macro create fake help > "out file.txt" ;')
+ assert out == normalize(create_command)
@pytest.mark.parametrize('macro_name', invalid_command_name)
def test_macro_create_invalid_name(base_app, macro_name):