Skip to content

Commit 710a9e2

Browse files
committed
Fixed unit tests
1 parent 255dd16 commit 710a9e2

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

tests/scripts/recursive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
Example demonstrating that running a Python script recursively inside another Python script isn't allowed
66
"""
77
app.cmd_echo = True
8-
app('pyscript ../script.py')
8+
app('run_pyscript ../script.py')

tests/test_cmd2.py

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -258,31 +258,31 @@ def test_base_run_pyscript(base_app, capsys, request):
258258
python_script = os.path.join(test_dir, 'script.py')
259259
expected = 'This is a python script running ...'
260260

261-
out, err = run_cmd(base_app, "pyscript {}".format(python_script))
261+
out, err = run_cmd(base_app, "run_pyscript {}".format(python_script))
262262
assert expected in out
263263

264-
def test_recursive_pyscript_not_allowed(base_app, request):
264+
def test_recursive_run_pyscript_not_allowed(base_app, request):
265265
test_dir = os.path.dirname(request.module.__file__)
266266
python_script = os.path.join(test_dir, 'scripts', 'recursive.py')
267267
expected = 'Recursively entering interactive Python consoles is not allowed.'
268268

269-
out, err = run_cmd(base_app, "pyscript {}".format(python_script))
269+
out, err = run_cmd(base_app, "run_pyscript {}".format(python_script))
270270
assert err[0] == expected
271271

272-
def test_pyscript_with_nonexist_file(base_app):
272+
def test_run_pyscript_with_nonexist_file(base_app):
273273
python_script = 'does_not_exist.py'
274-
out, err = run_cmd(base_app, "pyscript {}".format(python_script))
274+
out, err = run_cmd(base_app, "run_pyscript {}".format(python_script))
275275
assert "Error opening script file" in err[0]
276276

277-
def test_pyscript_with_exception(base_app, request):
277+
def test_run_pyscript_with_exception(base_app, request):
278278
test_dir = os.path.dirname(request.module.__file__)
279279
python_script = os.path.join(test_dir, 'scripts', 'raises_exception.py')
280-
out, err = run_cmd(base_app, "pyscript {}".format(python_script))
280+
out, err = run_cmd(base_app, "run_pyscript {}".format(python_script))
281281
assert err[0].startswith('Traceback')
282282
assert "TypeError: unsupported operand type(s) for +: 'int' and 'str'" in err[-1]
283283

284-
def test_pyscript_requires_an_argument(base_app):
285-
out, err = run_cmd(base_app, "pyscript")
284+
def test_run_pyscript_requires_an_argument(base_app):
285+
out, err = run_cmd(base_app, "run_pyscript")
286286
assert "the following arguments are required: script_path" in err[1]
287287

288288

@@ -950,8 +950,8 @@ def test_custom_help_menu(help_app):
950950
expected = normalize("""
951951
Documented commands (type help <topic>):
952952
========================================
953-
alias help load py quit shell squat
954-
edit history macro pyscript set shortcuts
953+
alias help load py quit run_script shell squat
954+
edit history macro pyscript run_pyscript set shortcuts
955955
956956
Undocumented commands:
957957
======================
@@ -1020,7 +1020,8 @@ def test_help_cat_base(helpcat_app):
10201020
10211021
Other
10221022
=====
1023-
alias help history load macro py pyscript quit set shell shortcuts
1023+
alias history macro pyscript run_pyscript set shortcuts
1024+
help load py quit run_script shell
10241025
10251026
Undocumented commands:
10261027
======================
@@ -1052,6 +1053,8 @@ def test_help_cat_verbose(helpcat_app):
10521053
py Invoke Python command or shell
10531054
pyscript Run a Python script file inside the console
10541055
quit Exit this application
1056+
run_pyscript Run a Python script file inside the console
1057+
run_script Run commands in script file that is encoded as either ASCII or UTF-8 text
10551058
set Set a settable parameter or show current settings of parameters
10561059
shell Execute a command as if at the OS prompt
10571060
shortcuts List available shortcuts
@@ -1600,7 +1603,7 @@ def test_poutput_color_never(outsim_app):
16001603

16011604
def test_get_alias_names(base_app):
16021605
assert len(base_app.aliases) == 0
1603-
run_cmd(base_app, 'alias create fake pyscript')
1606+
run_cmd(base_app, 'alias create fake run_pyscript')
16041607
run_cmd(base_app, 'alias create ls !ls -hal')
16051608
assert len(base_app.aliases) == 2
16061609
assert sorted(base_app.get_alias_names()) == ['fake', 'ls']
@@ -1621,7 +1624,7 @@ def test_alias_no_subcommand(base_app):
16211624

16221625
def test_alias_create(base_app):
16231626
# Create the alias
1624-
out, err = run_cmd(base_app, 'alias create fake pyscript')
1627+
out, err = run_cmd(base_app, 'alias create fake run_pyscript')
16251628
assert out == normalize("Alias 'fake' created")
16261629

16271630
# Use the alias
@@ -1630,11 +1633,11 @@ def test_alias_create(base_app):
16301633

16311634
# See a list of aliases
16321635
out, err = run_cmd(base_app, 'alias list')
1633-
assert out == normalize('alias create fake pyscript')
1636+
assert out == normalize('alias create fake run_pyscript')
16341637

16351638
# Look up the new alias
16361639
out, err = run_cmd(base_app, 'alias list fake')
1637-
assert out == normalize('alias create fake pyscript')
1640+
assert out == normalize('alias create fake run_pyscript')
16381641

16391642
def test_alias_create_with_quoted_value(base_app):
16401643
"""Demonstrate that quotes in alias value will be preserved (except for redirectors and terminators)"""
@@ -1675,7 +1678,7 @@ def test_alias_list_invalid_alias(base_app):
16751678

16761679
def test_alias_delete(base_app):
16771680
# Create an alias
1678-
run_cmd(base_app, 'alias create fake pyscript')
1681+
run_cmd(base_app, 'alias create fake run_pyscript')
16791682

16801683
# Delete the alias
16811684
out, err = run_cmd(base_app, 'alias delete fake')
@@ -1712,7 +1715,7 @@ def test_macro_no_subcommand(base_app):
17121715

17131716
def test_macro_create(base_app):
17141717
# Create the macro
1715-
out, err = run_cmd(base_app, 'macro create fake pyscript')
1718+
out, err = run_cmd(base_app, 'macro create fake run_pyscript')
17161719
assert out == normalize("Macro 'fake' created")
17171720

17181721
# Use the macro
@@ -1721,11 +1724,11 @@ def test_macro_create(base_app):
17211724

17221725
# See a list of macros
17231726
out, err = run_cmd(base_app, 'macro list')
1724-
assert out == normalize('macro create fake pyscript')
1727+
assert out == normalize('macro create fake run_pyscript')
17251728

17261729
# Look up the new macro
17271730
out, err = run_cmd(base_app, 'macro list fake')
1728-
assert out == normalize('macro create fake pyscript')
1731+
assert out == normalize('macro create fake run_pyscript')
17291732

17301733
def test_macro_create_with_quoted_value(base_app):
17311734
"""Demonstrate that quotes in macro value will be preserved (except for redirectors and terminators)"""
@@ -1829,7 +1832,7 @@ def test_macro_list_invalid_macro(base_app):
18291832

18301833
def test_macro_delete(base_app):
18311834
# Create an macro
1832-
run_cmd(base_app, 'macro create fake pyscript')
1835+
run_cmd(base_app, 'macro create fake run_pyscript')
18331836

18341837
# Delete the macro
18351838
out, err = run_cmd(base_app, 'macro delete fake')

0 commit comments

Comments
 (0)