Skip to content

Commit 6fa5c56

Browse files
committed
Added unit test
1 parent 273538c commit 6fa5c56

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tests/pyscript/stop.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# flake8: noqa F821
2+
app.cmd_echo = True
3+
app('help')
4+
5+
# This will set stop to True in the PyscriptBridge
6+
app('quit')
7+
8+
# Exercise py_quit() in unit test
9+
quit()

tests/test_pyscript.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,17 @@ def test_pyscript_stdout_capture(base_app, request):
4040

4141
assert out[0] == "PASSED"
4242
assert out[1] == "PASSED"
43+
44+
def test_pyscript_stop(base_app, request):
45+
# Verify onecmd_plus_hooks() returns True if any commands in a pyscript return True for stop
46+
test_dir = os.path.dirname(request.module.__file__)
47+
48+
# help.py doesn't run any commands that returns True for stop
49+
python_script = os.path.join(test_dir, 'pyscript', 'help.py')
50+
stop = base_app.onecmd_plus_hooks('pyscript {}'.format(python_script))
51+
assert not stop
52+
53+
# stop.py runs the quit command which does return True for stop
54+
python_script = os.path.join(test_dir, 'pyscript', 'stop.py')
55+
stop = base_app.onecmd_plus_hooks('pyscript {}'.format(python_script))
56+
assert stop

0 commit comments

Comments
 (0)