diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2021-01-24 11:07:50 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-24 11:07:50 -0500 |
commit | 44eb9d4e1946a3cc9a10fe85ccb617b6076f627c (patch) | |
tree | df5a6d6b7f9a173eb387e17408750a2ce57b84c2 /tests | |
parent | 5f1ea98c1513225c7bf87976ca438410afff2268 (diff) | |
parent | bc01feced61d493ad8a0e3cc3d5e4768e5d214be (diff) | |
download | cmd2-git-44eb9d4e1946a3cc9a10fe85ccb617b6076f627c.tar.gz |
Merge pull request #1045 from python-cmd2/silent_start
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] |