Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaner message when CLI can't load app #3711

Merged
merged 1 commit into from
Jul 31, 2020
Merged

cleaner message when CLI can't load app #3711

merged 1 commit into from
Jul 31, 2020

Conversation

davidism
Copy link
Member

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 to stderr 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 imported test_apps/helloworld/wsgi, one of the default imports that is tried if FLASK_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

When loading the app fails for the --help command, only the error
message is shown, then the help text. The full traceback is 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 to stderr 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.
@davidism davidism added this to the 2.0.0 milestone Jul 31, 2020
@davidism davidism added the cli label Jul 31, 2020
@davidism davidism merged commit 6638432 into master Jul 31, 2020
@davidism davidism deleted the cli-loading-error branch July 31, 2020 01:48
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better exception handling when env vars are missing for flask CLI
1 participant