Fix wrapped view function comparison
Wrapped functions are not comparable, see https://bugs.python.org/issue3564, therefore a marker is used to note when the function has been sync wrapped to allow comparison with the wrapped function instead. This ensures that multiple route decorators work without raising exceptions i.e., @app.route("/") @app.route("/a") async def index(): ... works.
This commit is contained in:
parent
3e6123f1cb
commit
2fe5f3d65c
3 changed files with 5 additions and 1 deletions
|
|
@ -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