forked from orbit-oss/flask
Merge pull request #3964 from pgjones/fix
Fix wrapped view function comparison
This commit is contained in:
commit
39887ee4df
3 changed files with 5 additions and 1 deletions
|
|
@ -1048,6 +1048,8 @@ class Flask(Scaffold):
|
|||
self.url_map.add(rule)
|
||||
if view_func is not None:
|
||||
old_func = self.view_functions.get(endpoint)
|
||||
if getattr(old_func, "_flask_sync_wrapper", False):
|
||||
old_func = old_func.__wrapped__
|
||||
if old_func is not None and old_func != view_func:
|
||||
raise AssertionError(
|
||||
"View function mapping is overwriting an existing"
|
||||
|
|
|
|||
|
|
@ -780,4 +780,5 @@ def run_async(func):
|
|||
|
||||
return async_to_sync(inner)(*args, **kwargs)
|
||||
|
||||
outer._flask_sync_wrapper = True
|
||||
return outer
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ def _async_app():
|
|||
app = Flask(__name__)
|
||||
|
||||
@app.route("/", methods=["GET", "POST"])
|
||||
@app.route("/home", methods=["GET", "POST"])
|
||||
async def index():
|
||||
await asyncio.sleep(0)
|
||||
return request.method
|
||||
|
|
@ -57,7 +58,7 @@ def _async_app():
|
|||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires Python >= 3.7")
|
||||
@pytest.mark.parametrize("path", ["/", "/bp/"])
|
||||
@pytest.mark.parametrize("path", ["/", "/home", "/bp/"])
|
||||
def test_async_route(path, async_app):
|
||||
test_client = async_app.test_client()
|
||||
response = test_client.get(path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue