diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-04-23 23:38:06 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-04-23 23:38:06 -0400 |
commit | 034ee380d549cee507e80344e87bc016549750eb (patch) | |
tree | 556c808b2ad3d2c5004cfc2f9277865ee14eaab7 /tests/pyscript | |
parent | ca7f24b238cdfd67adddec0146e7519352589484 (diff) | |
download | cmd2-git-034ee380d549cee507e80344e87bc016549750eb.tar.gz |
Added unit test for stdout capture in pyscript
Diffstat (limited to 'tests/pyscript')
-rw-r--r-- | tests/pyscript/stdout_capture.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/pyscript/stdout_capture.py b/tests/pyscript/stdout_capture.py new file mode 100644 index 00000000..dfc39627 --- /dev/null +++ b/tests/pyscript/stdout_capture.py @@ -0,0 +1,20 @@ +# flake8: noqa F821 +# This script demonstrates when output of a command finalization hook is captured by a pyscript app() call +import sys + +# The unit test framework passes in the string being printed by the command finalization hook +hook_output = sys.argv[1] + +# hook_output will not be captured because there are no nested calls to onecmd_plus_hooks +res = app('help') +if hook_output not in res.stdout: + print("PASSED") +else: + print("FAILED") + +# hook_output will be captured in the nested call to onecmd_plus_hooks that occurs in do_history() +res = app('history -r -1') +if hook_output in res.stdout: + print("PASSED") +else: + print("FAILED") |