Browse Source

Merge pull request #2217 from edbrannin/patch-1

shorten output when ImportError due to app bug.
pull/2066/merge
David Lord 8 years ago committed by GitHub
parent
commit
19d7e6532f
  1. 4
      flask/cli.py
  2. 2
      tests/test_cli.py

4
flask/cli.py

@ -93,7 +93,9 @@ def locate_app(app_id):
# Reraise the ImportError if it occurred within the imported module. # Reraise the ImportError if it occurred within the imported module.
# Determine this by checking whether the trace has a depth > 1. # Determine this by checking whether the trace has a depth > 1.
if sys.exc_info()[-1].tb_next: if sys.exc_info()[-1].tb_next:
raise stack_trace = traceback.format_exc()
raise NoAppException('There was an error trying to import'
' the app (%s):\n%s' % (module, stack_trace))
else: else:
raise NoAppException('The file/path provided (%s) does not appear' raise NoAppException('The file/path provided (%s) does not appear'
' to exist. Please verify the path is ' ' to exist. Please verify the path is '

2
tests/test_cli.py

@ -83,7 +83,7 @@ def test_locate_app(test_apps):
pytest.raises(NoAppException, locate_app, "notanpp.py") pytest.raises(NoAppException, locate_app, "notanpp.py")
pytest.raises(NoAppException, locate_app, "cliapp/app") pytest.raises(NoAppException, locate_app, "cliapp/app")
pytest.raises(RuntimeError, locate_app, "cliapp.app:notanapp") pytest.raises(RuntimeError, locate_app, "cliapp.app:notanapp")
pytest.raises(ImportError, locate_app, "cliapp.importerrorapp") pytest.raises(NoAppException, locate_app, "cliapp.importerrorapp")
def test_find_default_import_path(test_apps, monkeypatch, tmpdir): def test_find_default_import_path(test_apps, monkeypatch, tmpdir):

Loading…
Cancel
Save