diff --git a/src/flask/app.py b/src/flask/app.py index 794ae095..a68c8c55 100644 --- a/src/flask/app.py +++ b/src/flask/app.py @@ -1085,16 +1085,27 @@ class Flask(Scaffold): # Check HTTP method supported_http_methods = { - "GET", "POST", "PUT", "PATCH", "DELETE", - "HEAD", "CONNECT", "OPTIONS", "TRACE", - "COPY", "LINK", "UNLINK", "PURGE", - "LOCK", "UNLOCK", "PROFIND", "VIEW" + "GET", + "POST", + "PUT", + "PATCH", + "DELETE", + "HEAD", + "CONNECT", + "OPTIONS", + "TRACE", + "COPY", + "LINK", + "UNLINK", + "PURGE", + "LOCK", + "UNLOCK", + "PROFIND", + "VIEW", } for item in methods: if item not in supported_http_methods: - raise TypeError( - f"'{item}' method is not specified in HTTP." - ) + raise TypeError(f"'{item}' method is not specified in HTTP.") rule = self.url_rule_class(rule, methods=methods, **options) rule.provide_automatic_options = provide_automatic_options # type: ignore diff --git a/tests/test_basic.py b/tests/test_basic.py index eb62a491..f5fb18ff 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -2029,8 +2029,9 @@ def test_app_freed_on_zero_refcount(): def test_validate_http_method_route(app, client): - + with pytest.raises(TypeError): + @app.route("/", methods=["BAD_METHOD"]) def bad_method_func(): - return "Hello World" \ No newline at end of file + return "Hello World"