Make CLI test failures verbose by not catching exceptions in the test runner#2220
Merged
Conversation
Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot
AI
changed the title
feat: add CustomFlaskCliRunner to propagate exceptions in CLI tests
Make CLI test failures verbose by not catching exceptions in the test runner
Jun 2, 2026
Copilot created this pull request from a session on behalf of
Flix6x
June 2, 2026 21:28
View session
Flix6x
approved these changes
Jun 2, 2026
…-tracking-capacity # Conflicts: # flexmeasures/cli/tests/test_utils.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a CLI test fails, the default
FlaskCliRunnerswallows exceptions and surfaces only a non-zero exit code, forcing developers to hunt for the root cause manually.Changes
flexmeasures/conftest.py: addsCustomFlaskCliRunner— aFlaskCliRunnersubclass that defaultscatch_exceptions=False— and sets it astest_cli_runner_classon the test app, so all existingapp.test_cli_runner()calls get verbose exceptions for free with no per-test changes.flexmeasures/cli/tests/test_utils.py: adds astrictxfailtest that invokes a command raisingRuntimeError. It must fail (XFAIL); if exceptions start being silently caught again the test unexpectedly passes (XPASS), breaking the suite.