diff options
| author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-09-17 23:44:07 -0400 |
|---|---|---|
| committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-09-17 23:44:07 -0400 |
| commit | 0f11ffa3b992e3f777b96dfe46d4274bfca0dcc8 (patch) | |
| tree | 8167147ff11f5c9c7aaf1008555248c9c1cd7850 /tests | |
| parent | c50def1eff00f7f44adcb911d215ace65d16aa8a (diff) | |
| parent | d348f09cf848a566a43b30e04aa6d3adbc4de8bc (diff) | |
| download | cmd2-git-0f11ffa3b992e3f777b96dfe46d4274bfca0dcc8.tar.gz | |
Merge branch 'master' into 2.0
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/test_cmd2.py | 30 | ||||
| -rw-r--r-- | tests/test_utils.py | 7 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index f5c8dbc6..d913b4fc 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -1660,6 +1660,21 @@ def test_alias_create(base_app): out, err = run_cmd(base_app, 'alias list fake') assert out == normalize('alias create fake run_pyscript') + # Overwrite alias + out, err = run_cmd(base_app, 'alias create fake help') + assert out == normalize("Alias 'fake' overwritten") + + # Look up the updated alias + out, err = run_cmd(base_app, 'alias list fake') + assert out == normalize('alias create fake help') + + # Test silent flag + out, err = run_cmd(base_app, 'alias create --silent fake set') + assert not out + + 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)""" @@ -1754,6 +1769,21 @@ def test_macro_create(base_app): out, err = run_cmd(base_app, 'macro list fake') assert out == normalize('macro create fake run_pyscript') + # Overwrite macro + out, err = run_cmd(base_app, 'macro create fake help') + assert out == normalize("Macro 'fake' overwritten") + + # Look up the updated macro + out, err = run_cmd(base_app, 'macro list fake') + assert out == normalize('macro create fake help') + + # Test silent flag + out, err = run_cmd(base_app, 'macro create --silent fake set') + assert not out + + 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)""" # Create the macro diff --git a/tests/test_utils.py b/tests/test_utils.py index 27bf4743..2c94466c 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -154,6 +154,13 @@ def test_stdsim_read(stdout_sim): assert stdout_sim.read() == my_str assert stdout_sim.getvalue() == '' + stdout_sim.write(my_str) + + assert stdout_sim.getvalue() == my_str + assert stdout_sim.read(2) == my_str[:2] + assert stdout_sim.getvalue() == my_str[2:] + + def test_stdsim_read_bytes(stdout_sim): b_str = b'Hello World' stdout_sim.buffer.write(b_str) |
