Skip to content
Myr

Merge pull request #3964 from pgjones/fix

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix wrapped view function comparison

authored by David Lord · committed by GitHub · parents fab26dc, 5c6a0f0 · Browse files · 3 files+5 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+5 added−1 removed

  • tests:+2 added−1 removed
  • other:+3 added−0 removed

3 files+5 added−1 removed

modified:src/flask/app.py+2 added
1046 unmodified lines
10471048 self.url_map.add(rule)1049 if view_func is not None:1050 old_func = self.view_functions.get(endpoint)1051 if getattr(old_func, "_flask_sync_wrapper", False):1052 old_func = old_func.__wrapped__1053 if old_func is not None and old_func != view_func:1054 raise AssertionError(1055 "View function mapping is overwriting an existing"1056 f" endpoint function: {endpoint}"
921 unmodified lines
modified:src/flask/helpers.py+1 added
778 unmodified lines
779 return await func(*a, **k)780781 return async_to_sync(inner)(*args, **kwargs)782783 outer._flask_sync_wrapper = True784 return outer
modified:tests/test_async.py+2 added-1 removed
22 unmodified lines
23def _async_app():24 app = Flask(__name__)2526 @app.route("/", methods=["GET", "POST"])27 @app.route("/home", methods=["GET", "POST"])28 async def index():29 await asyncio.sleep(0)30 return request.method31
25 unmodified lines
57 return app585960@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires Python >= 3.7")60@pytest.mark.parametrize("path", ["/", "/bp/"])61@pytest.mark.parametrize("path", ["/", "/home", "/bp/"])62def test_async_route(path, async_app):63 test_client = async_app.test_client()64 response = test_client.get(path)65 assert b"GET" in response.get_data()
75 unmodified lines