summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd2/py_bridge.py5
-rw-r--r--tests_isolated/test_commandset/test_commandset.py10
2 files changed, 5 insertions, 10 deletions
diff --git a/cmd2/py_bridge.py b/cmd2/py_bridge.py
index cd81c6b8..7570c1a8 100644
--- a/cmd2/py_bridge.py
+++ b/cmd2/py_bridge.py
@@ -33,7 +33,6 @@ class CommandResult(NamedTuple):
:stdout: str - output captured from stdout while this command is executing
:stderr: str - output captured from stderr while this command is executing
- None if no error captured.
:stop: bool - return value of onecmd_plus_hooks after it runs the given
command line.
:data: possible data populated by the command.
@@ -66,7 +65,7 @@ class CommandResult(NamedTuple):
"""
stdout: str = ''
- stderr: Optional[str] = None
+ stderr: str = ''
stop: bool = False
data: Any = None
@@ -135,7 +134,7 @@ class PyBridge:
# Save the output. If stderr is empty, set it to None.
result = CommandResult(
stdout=copy_cmd_stdout.getvalue(),
- stderr=copy_stderr.getvalue() if copy_stderr.getvalue() else None,
+ stderr=copy_stderr.getvalue(),
stop=stop,
data=self._cmd2_app.last_result,
)
diff --git a/tests_isolated/test_commandset/test_commandset.py b/tests_isolated/test_commandset/test_commandset.py
index 2e7d837f..4f89d475 100644
--- a/tests_isolated/test_commandset/test_commandset.py
+++ b/tests_isolated/test_commandset/test_commandset.py
@@ -257,28 +257,24 @@ def test_commandset_decorators(command_sets_app):
assert 'extra1' in result.data['unknown']
assert 'extra2' in result.data['unknown']
assert result.data['arg1'] == 'juice'
- assert result.stderr is None
+ assert not result.stderr
result = command_sets_app.app_cmd('durian juice extra1 extra2')
assert len(result.data['args']) == 3
assert 'juice' in result.data['args']
assert 'extra1' in result.data['args']
assert 'extra2' in result.data['args']
- assert result.stderr is None
+ assert not result.stderr
result = command_sets_app.app_cmd('durian')
assert len(result.data['args']) == 0
- assert result.stderr is None
+ assert not result.stderr
result = command_sets_app.app_cmd('elderberry')
- assert result.stderr is not None
- assert len(result.stderr) > 0
assert 'arguments are required' in result.stderr
assert result.data is None
result = command_sets_app.app_cmd('elderberry a b')
- assert result.stderr is not None
- assert len(result.stderr) > 0
assert 'unrecognized arguments' in result.stderr
assert result.data is None