summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-15 01:26:32 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-15 01:26:32 -0400
commit3c0a31399ced7f6e9eb0d63a6c073b27d42034ff (patch)
tree386829fcff9bf04f305f93c3b66bd10d63d2e549 /tests
parentb3df078bdb3d0472487cfce4185f922eb7f1843b (diff)
downloadcmd2-git-3c0a31399ced7f6e9eb0d63a6c073b27d42034ff.tar.gz
Added unit tests
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cmd2.py15
-rw-r--r--tests/test_run_pyscript.py13
2 files changed, 16 insertions, 12 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index acf9d610..a8278351 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -258,7 +258,7 @@ def test_base_error(base_app):
assert "is not a recognized command" in err[0]
-def test_base_run_script(base_app, request):
+def test_run_script(base_app, request):
test_dir = os.path.dirname(request.module.__file__)
filename = os.path.join(test_dir, 'script.txt')
@@ -285,6 +285,11 @@ def test_base_run_script(base_app, request):
assert script_out == manual_out
assert script_err == manual_err
+def test_load_deprecated(base_app):
+ """Delete this when load alias is removed"""
+ _, err = run_cmd(base_app, "load fake")
+ assert "load has been renamed and will be removed" in err[0]
+
def test_run_script_with_empty_args(base_app):
out, err = run_cmd(base_app, 'run_script')
assert "the following arguments are required" in err[1]
@@ -359,7 +364,7 @@ set colors Never""" % initial_run
out, err = run_cmd(base_app, 'history -s')
assert out == normalize(expected)
-def test_base_runcmds_plus_hooks(base_app, request):
+def test_runcmds_plus_hooks(base_app, request):
test_dir = os.path.dirname(request.module.__file__)
prefilepath = os.path.join(test_dir, 'scripts', 'precmds.txt')
postfilepath = os.path.join(test_dir, 'scripts', 'postcmds.txt')
@@ -379,7 +384,7 @@ set colors Never""" % (prefilepath, postfilepath)
out, err = run_cmd(base_app, 'history -s')
assert out == normalize(expected)
-def test_base_relative_run_script(base_app, request):
+def test_relative_run_script(base_app, request):
test_dir = os.path.dirname(request.module.__file__)
filename = os.path.join(test_dir, 'script.txt')
@@ -410,6 +415,10 @@ def test_relative_run_script_requires_an_argument(base_app):
out, err = run_cmd(base_app, '_relative_run_script')
assert 'Error: the following arguments' in err[1]
+def test_relative_load_deprecated(base_app):
+ """Delete this when _relative_load alias is removed"""
+ _, err = run_cmd(base_app, "_relative_load fake")
+ assert "_relative_load has been renamed and will be removed" in err[0]
def test_output_redirection(base_app):
fd, filename = tempfile.mkstemp(prefix='cmd2_test', suffix='.txt')
diff --git a/tests/test_run_pyscript.py b/tests/test_run_pyscript.py
index 088d9aab..c8b44271 100644
--- a/tests/test_run_pyscript.py
+++ b/tests/test_run_pyscript.py
@@ -15,7 +15,7 @@ def cmdfinalization_hook(data: plugin.CommandFinalizationData) -> plugin.Command
print(HOOK_OUTPUT)
return data
-def test_run_pyscript_base(base_app, request):
+def test_run_pyscript(base_app, request):
test_dir = os.path.dirname(request.module.__file__)
python_script = os.path.join(test_dir, 'script.py')
expected = 'This is a python script running ...'
@@ -85,12 +85,7 @@ def test_run_pyscript_stop(base_app, request):
stop = base_app.onecmd_plus_hooks('run_pyscript {}'.format(python_script))
assert stop
-def test_pyscript_deprecated_but_works(base_app, request):
- test_dir = os.path.dirname(request.module.__file__)
- python_script = os.path.join(test_dir, 'script.py')
- expected = 'This is a python script running ...'
-
- out, err = run_cmd(base_app, "pyscript {}".format(python_script))
- assert expected in out
+def test_pyscript_deprecated(base_app):
+ """Delete this when pyscript alias is removed"""
+ _, err = run_cmd(base_app, "pyscript fake")
assert "pyscript has been renamed and will be removed" in err[0]
-