Skip to content

Commit

Permalink
Tests: Print stack trace if CLI command excepts with run_cli_command
Browse files Browse the repository at this point in the history
Before, the test would just fail and say that an exception was raised
but it would not display the actual exception, making it difficult to
debug the problem. In the case of a non-zero exit code, the stderr is
printed as well.
  • Loading branch information
sphuber committed Oct 11, 2023
1 parent 6625fd2 commit 08cba0f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,9 @@ def factory(
assert result.exception is not None, result.output
assert result.exit_code != 0, result.exit_code
else:
assert result.exception is None, result.output
assert result.exit_code == 0, result.exit_code
import traceback
assert result.exception is None, ''.join(traceback.format_exception(*result.exc_info))
assert result.exit_code == 0, (result.exit_code, result.stderr)

return result

Expand Down

0 comments on commit 08cba0f

Please sign in to comment.