Skip to content

Commit 3c0a313

Browse files
committed
Added unit tests
1 parent b3df078 commit 3c0a313

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

tests/test_cmd2.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def test_base_error(base_app):
258258
assert "is not a recognized command" in err[0]
259259

260260

261-
def test_base_run_script(base_app, request):
261+
def test_run_script(base_app, request):
262262
test_dir = os.path.dirname(request.module.__file__)
263263
filename = os.path.join(test_dir, 'script.txt')
264264

@@ -285,6 +285,11 @@ def test_base_run_script(base_app, request):
285285
assert script_out == manual_out
286286
assert script_err == manual_err
287287

288+
def test_load_deprecated(base_app):
289+
"""Delete this when load alias is removed"""
290+
_, err = run_cmd(base_app, "load fake")
291+
assert "load has been renamed and will be removed" in err[0]
292+
288293
def test_run_script_with_empty_args(base_app):
289294
out, err = run_cmd(base_app, 'run_script')
290295
assert "the following arguments are required" in err[1]
@@ -359,7 +364,7 @@ def test_run_script_nested_run_scripts(base_app, request):
359364
out, err = run_cmd(base_app, 'history -s')
360365
assert out == normalize(expected)
361366

362-
def test_base_runcmds_plus_hooks(base_app, request):
367+
def test_runcmds_plus_hooks(base_app, request):
363368
test_dir = os.path.dirname(request.module.__file__)
364369
prefilepath = os.path.join(test_dir, 'scripts', 'precmds.txt')
365370
postfilepath = os.path.join(test_dir, 'scripts', 'postcmds.txt')
@@ -379,7 +384,7 @@ def test_base_runcmds_plus_hooks(base_app, request):
379384
out, err = run_cmd(base_app, 'history -s')
380385
assert out == normalize(expected)
381386

382-
def test_base_relative_run_script(base_app, request):
387+
def test_relative_run_script(base_app, request):
383388
test_dir = os.path.dirname(request.module.__file__)
384389
filename = os.path.join(test_dir, 'script.txt')
385390

@@ -410,6 +415,10 @@ def test_relative_run_script_requires_an_argument(base_app):
410415
out, err = run_cmd(base_app, '_relative_run_script')
411416
assert 'Error: the following arguments' in err[1]
412417

418+
def test_relative_load_deprecated(base_app):
419+
"""Delete this when _relative_load alias is removed"""
420+
_, err = run_cmd(base_app, "_relative_load fake")
421+
assert "_relative_load has been renamed and will be removed" in err[0]
413422

414423
def test_output_redirection(base_app):
415424
fd, filename = tempfile.mkstemp(prefix='cmd2_test', suffix='.txt')

tests/test_run_pyscript.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def cmdfinalization_hook(data: plugin.CommandFinalizationData) -> plugin.Command
1515
print(HOOK_OUTPUT)
1616
return data
1717

18-
def test_run_pyscript_base(base_app, request):
18+
def test_run_pyscript(base_app, request):
1919
test_dir = os.path.dirname(request.module.__file__)
2020
python_script = os.path.join(test_dir, 'script.py')
2121
expected = 'This is a python script running ...'
@@ -85,12 +85,7 @@ def test_run_pyscript_stop(base_app, request):
8585
stop = base_app.onecmd_plus_hooks('run_pyscript {}'.format(python_script))
8686
assert stop
8787

88-
def test_pyscript_deprecated_but_works(base_app, request):
89-
test_dir = os.path.dirname(request.module.__file__)
90-
python_script = os.path.join(test_dir, 'script.py')
91-
expected = 'This is a python script running ...'
92-
93-
out, err = run_cmd(base_app, "pyscript {}".format(python_script))
94-
assert expected in out
88+
def test_pyscript_deprecated(base_app):
89+
"""Delete this when pyscript alias is removed"""
90+
_, err = run_cmd(base_app, "pyscript fake")
9591
assert "pyscript has been renamed and will be removed" in err[0]
96-

0 commit comments

Comments
 (0)