diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-01-22 15:48:56 -0500 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-01-22 16:32:16 -0500 |
commit | 38b509932a2a538a472918f29d7f030334fca272 (patch) | |
tree | 7c4ef9612ab474c512e2ae3b3f25e6e03f64054d /tests | |
parent | a3b1b6ddf81cdc0b253f15feeb167ff348afd14f (diff) | |
download | cmd2-git-38b509932a2a538a472918f29d7f030334fca272.tar.gz |
Added option to run startup scripts silently
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_cmd2.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index a2299abe..d523bb8f 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -2399,15 +2399,24 @@ def test_disabled_message_command_name(disable_commands_app): out, err = run_cmd(disable_commands_app, 'has_helper_funcs') assert err[0].startswith('has_helper_funcs is currently disabled') - -def test_startup_script(request): +@pytest.mark.parametrize('silent_startup_script', [ + True, + False +]) +def test_startup_script(request, capsys, silent_startup_script): test_dir = os.path.dirname(request.module.__file__) startup_script = os.path.join(test_dir, '.cmd2rc') - app = cmd2.Cmd(allow_cli_args=False, startup_script=startup_script) + app = cmd2.Cmd(allow_cli_args=False, startup_script=startup_script, silent_startup_script=silent_startup_script) assert len(app._startup_commands) == 1 - assert app._startup_commands[0] == "run_script {}".format(utils.quote_string(startup_script)) app._startup_commands.append('quit') app.cmdloop() + + out, err = capsys.readouterr() + if silent_startup_script: + assert not out + else: + assert out + out, err = run_cmd(app, 'alias list') assert len(out) > 1 assert 'alias create ls' in out[0] |