summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-10 10:23:53 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-10 10:23:53 -0400
commit6fa5c56a0d457fa69ac43b1d0b6f733a71a697da (patch)
tree2d259cdb6b47ad628600e541b9c14fcf6bd45d58 /tests
parent273538ca647d9f50a92f11df621c26d2a65a3cc1 (diff)
downloadcmd2-git-6fa5c56a0d457fa69ac43b1d0b6f733a71a697da.tar.gz
Added unit test
Diffstat (limited to 'tests')
-rw-r--r--tests/pyscript/stop.py9
-rw-r--r--tests/test_pyscript.py14
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/pyscript/stop.py b/tests/pyscript/stop.py
new file mode 100644
index 00000000..e731218e
--- /dev/null
+++ b/tests/pyscript/stop.py
@@ -0,0 +1,9 @@
+# flake8: noqa F821
+app.cmd_echo = True
+app('help')
+
+# This will set stop to True in the PyscriptBridge
+app('quit')
+
+# Exercise py_quit() in unit test
+quit()
diff --git a/tests/test_pyscript.py b/tests/test_pyscript.py
index 4866548b..8da4b35a 100644
--- a/tests/test_pyscript.py
+++ b/tests/test_pyscript.py
@@ -40,3 +40,17 @@ def test_pyscript_stdout_capture(base_app, request):
assert out[0] == "PASSED"
assert out[1] == "PASSED"
+
+def test_pyscript_stop(base_app, request):
+ # Verify onecmd_plus_hooks() returns True if any commands in a pyscript return True for stop
+ test_dir = os.path.dirname(request.module.__file__)
+
+ # help.py doesn't run any commands that returns True for stop
+ python_script = os.path.join(test_dir, 'pyscript', 'help.py')
+ stop = base_app.onecmd_plus_hooks('pyscript {}'.format(python_script))
+ assert not stop
+
+ # stop.py runs the quit command which does return True for stop
+ python_script = os.path.join(test_dir, 'pyscript', 'stop.py')
+ stop = base_app.onecmd_plus_hooks('pyscript {}'.format(python_script))
+ assert stop