summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-10-05 15:46:35 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-10-05 15:46:35 -0400
commitc480f3a2e940757a6698f9270db503ebf4111fd7 (patch)
tree67f1af30a0361be162587cc3c988dccdd72bdfaa /tests/test_cmd2.py
parent9fee6105210b36201b5d2edc610f20bd67eac9f2 (diff)
downloadcmd2-git-c480f3a2e940757a6698f9270db503ebf4111fd7.tar.gz
No longer using stderr and self.data together to determine truthiness of a CommandResult.
Either self.data is used or if that's not possible, then self.stderr is used. This provided applications the ability to print to stderr even if an error didn't occur.
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r--tests/test_cmd2.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index a64f21e4..a2bd6197 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -1576,8 +1576,14 @@ class CommandResultApp(cmd2.Cmd):
self._last_result = cmd2.CommandResult(arg, data=True)
def do_negative(self, arg):
+ self._last_result = cmd2.CommandResult(arg, data=False)
+
+ def do_affirmative_no_data(self, arg):
self._last_result = cmd2.CommandResult(arg)
+ def do_negative_no_data(self, arg):
+ self._last_result = cmd2.CommandResult('', arg)
+
@pytest.fixture
def commandresult_app():
app = CommandResultApp()
@@ -1590,11 +1596,19 @@ def test_commandresult_truthy(commandresult_app):
assert commandresult_app._last_result
assert commandresult_app._last_result == cmd2.CommandResult(arg, data=True)
+ run_cmd(commandresult_app, 'affirmative_no_data {}'.format(arg))
+ assert commandresult_app._last_result
+ assert commandresult_app._last_result == cmd2.CommandResult(arg)
+
def test_commandresult_falsy(commandresult_app):
arg = 'bar'
run_cmd(commandresult_app, 'negative {}'.format(arg))
assert not commandresult_app._last_result
- assert commandresult_app._last_result == cmd2.CommandResult(arg)
+ assert commandresult_app._last_result == cmd2.CommandResult(arg, data=False)
+
+ run_cmd(commandresult_app, 'negative_no_data {}'.format(arg))
+ assert not commandresult_app._last_result
+ assert commandresult_app._last_result == cmd2.CommandResult('', arg)
def test_is_text_file_bad_input(base_app):