cleaner message when CLI can't load app #3711
Merged
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 loading the app fails for the
--help
command, only the error message is shown, then the help text. The full traceback is still shown for other exceptions. Also show the message when loading fails while getting a command, instead of only "command not found". The error message goes tostderr
to match other error behavior, and is in red with an extra newline to make it more obvious next to the help text.Also fixes an issue with the
test_apps
fixture that caused an imported app to still be importable after the test was over and the path was reset. Now the module cache is reset as well. This was causing an issue with the new tests, because previous tests had importedtest_apps/helloworld/wsgi
, one of the default imports that is tried ifFLASK_APP
isn't set, which caused the test to import an app successfully even though it should have failed and shown an error. This also revealed an issue with an existing test relying on the cached behavior.fixes #2741