diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-06-29 20:47:46 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-06-29 20:47:46 -0400 |
commit | 519f0844374db12aa08a0f9f8c185bacb1f4ca2e (patch) | |
tree | b143549983896154acf59a3308519aae10eab187 /tests | |
parent | 324c44871e43599fd05a1e95f3c36b1986ca2f64 (diff) | |
download | cmd2-git-519f0844374db12aa08a0f9f8c185bacb1f4ca2e.tar.gz |
Added unit test for startup_script functionality
Diffstat (limited to 'tests')
-rw-r--r-- | tests/.cmd2rc | 2 | ||||
-rw-r--r-- | tests/test_cmd2.py | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/.cmd2rc b/tests/.cmd2rc new file mode 100644 index 00000000..cedcbe20 --- /dev/null +++ b/tests/.cmd2rc @@ -0,0 +1,2 @@ +alias create ls !ls -hal +alias create pwd !pwd diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index e8362afb..ded43d83 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -2144,3 +2144,16 @@ def test_disabled_message_command_name(disable_commands_app): out, err = run_cmd(disable_commands_app, 'has_help_func') assert err[0].startswith('has_help_func is currently disabled') + + +def test_startup_script(request): + test_dir = os.path.dirname(request.module.__file__) + startup_script = os.path.join(os.path.dirname(__file__), '.cmd2rc') + app = cmd2.Cmd(allow_cli_args=False, startup_script=startup_script) + assert len(app._startup_commands) == 1 + assert app._startup_commands[0] == "run_script '{}'".format(startup_script) + app._startup_commands.append('quit') + app.cmdloop() + out, err = run_cmd(app, 'alias list') + assert len(out) > 1 + assert 'alias create ls' in out[0] |