diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-26 23:07:32 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-26 23:07:32 -0400 |
commit | 2315338a5986b1d2fa64d0b6cc15b2659e80c3ee (patch) | |
tree | fe8fefa4b77d1d0c0f96eafc642a7a7c34cb424c /tests/test_cmd2.py | |
parent | 7b334ecf9b189c96644d599c84eb6d0fdc5ddddf (diff) | |
download | cmd2-git-2315338a5986b1d2fa64d0b6cc15b2659e80c3ee.tar.gz |
Even more unit tests
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r-- | tests/test_cmd2.py | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 0468dd36..c6578756 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -1813,7 +1813,25 @@ def test_alias_create(base_app, capsys): out = run_cmd(base_app, 'alias list fake') assert out == normalize('alias create fake pyscript') -def test_alias_create_with_quotes(base_app, capsys): +def test_alias_quoted_name(base_app, capsys): + """Demonstrate that names can be quoted in alias commands because they will be stripped""" + # Create the alias + out = run_cmd(base_app, 'alias create "fake" pyscript') + + # The quotes on names are stripped + assert out == normalize("Alias 'fake' created") + + # Look up the new alias and quote the name + out = run_cmd(base_app, 'alias list "fake"') + assert out == normalize('alias create fake pyscript') + + # Delete the alias using quotes + out = run_cmd(base_app, 'alias delete "fake"') + assert out == normalize("Alias 'fake' deleted") + +def test_alias_create_with_quoted_value(base_app, capsys): + """Demonstrate that quotes in alias value will be preserved (except for redirectors)""" + # Create the alias out = run_cmd(base_app, 'alias create fake help ">" "out file.txt"') assert out == normalize("Alias 'fake' created") @@ -1897,7 +1915,24 @@ def test_macro_create(base_app, capsys): out = run_cmd(base_app, 'macro list fake') assert out == normalize('macro create fake pyscript') -def test_macro_create_with_quotes(base_app, capsys): +def test_macro_create_quoted_name(base_app, capsys): + """Demonstrate that names can be quoted in macro commands because they will be stripped""" + # Create the macro + out = run_cmd(base_app, 'macro create "fake" pyscript') + + # The quotes on names are stripped + assert out == normalize("Macro 'fake' created") + + # Look up the new macro and quote the name + out = run_cmd(base_app, 'macro list "fake"') + assert out == normalize('macro create fake pyscript') + + # Delete the macro using quotes + out = run_cmd(base_app, 'macro delete "fake"') + assert out == normalize("Macro 'fake' deleted") + +def test_macro_create_with_quoted_value(base_app, capsys): + """Demonstrate that quotes in macro value will be preserved (except for redirectors)""" # Create the macro out = run_cmd(base_app, 'macro create fake help ">" "out file.txt"') assert out == normalize("Macro 'fake' created") |