refactor lazy loading
Remove the `--eager-loading/--lazy-loading` options and the `DispatchingApp` middleware. The `run` command handles loading exceptions directly. The reloader always prints out tracebacks immediately and always defers raising the error.
This commit is contained in:
parent
095651be9e
commit
5d8e35653f
6 changed files with 31 additions and 118 deletions
|
|
@ -1,7 +1,6 @@
|
|||
# This file was part of Flask-CLI and was modified under the terms of
|
||||
# its Revised BSD License. Copyright © 2015 CERN.
|
||||
import os
|
||||
import platform
|
||||
import ssl
|
||||
import sys
|
||||
import types
|
||||
|
|
@ -17,7 +16,6 @@ from flask import Blueprint
|
|||
from flask import current_app
|
||||
from flask import Flask
|
||||
from flask.cli import AppGroup
|
||||
from flask.cli import DispatchingApp
|
||||
from flask.cli import find_best_app
|
||||
from flask.cli import FlaskGroup
|
||||
from flask.cli import get_version
|
||||
|
|
@ -290,26 +288,6 @@ def test_scriptinfo(test_apps, monkeypatch):
|
|||
assert app.name == "testapp"
|
||||
|
||||
|
||||
@pytest.mark.xfail(platform.python_implementation() == "PyPy", reason="flaky on pypy")
|
||||
def test_lazy_load_error(monkeypatch):
|
||||
"""When using lazy loading, the correct exception should be
|
||||
re-raised.
|
||||
"""
|
||||
|
||||
class BadExc(Exception):
|
||||
pass
|
||||
|
||||
def bad_load():
|
||||
raise BadExc
|
||||
|
||||
lazy = DispatchingApp(bad_load, use_eager_loading=False)
|
||||
|
||||
# reduce flakiness by waiting for the internal loading lock
|
||||
with lazy._lock:
|
||||
with pytest.raises(BadExc):
|
||||
lazy._flush_bg_loading_exception()
|
||||
|
||||
|
||||
def test_app_cli_has_app_context(app, runner):
|
||||
def _param_cb(ctx, param, value):
|
||||
# current_app should be available in parameter callbacks
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue