Skip to content

Commit 386130d

Browse files
committed
Fix inverted logic in TracebackHandler.abort
1 parent 0908288 commit 386130d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

consolekit/tracebacks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def abort(self, msg: Union[str, List[str]]) -> "NoReturn":
103103
If a list of strings the strings are concatenated (i.e. ``''.join(msg)``).
104104
"""
105105

106-
if isinstance(msg, str):
106+
if not isinstance(msg, str):
107107
msg = ''.join(msg)
108108

109109
if msg:

tests/test_tracebacks.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,18 @@ def main(show_traceback: bool):
186186
result = cli_runner.invoke(main, args="-h")
187187
result.check_stdout(file_regression)
188188
assert result.exit_code == 0
189+
190+
191+
def test_traceback_handler_abort(capsys):
192+
193+
TH = TracebackHandler(ValueError("foo"))
194+
195+
with pytest.raises(ValueError, match="foo$"):
196+
TH.abort("Hello World")
197+
198+
assert capsys.readouterr().err == "Hello World\n"
199+
200+
with pytest.raises(ValueError, match="foo$"):
201+
TH.abort(["Hello", "Everybody"])
202+
203+
assert capsys.readouterr().err == "HelloEverybody\n"

0 commit comments

Comments
 (0)