MCPcopy Create free account
hub / github.com/pallets/quart / test_view_decorators

Function test_view_decorators

tests/test_views.py:56–77  ·  view source on GitHub ↗
(app: Quart)

Source from the content-addressed store, hash-verified

54
55
56async def test_view_decorators(app: Quart) -> None:
57 def decorate_status_code(func: Callable) -> Callable:
58 async def wrapper(*args: Any, **kwargs: Any) -> ResponseReturnValue:
59 response = await func(*args, **kwargs)
60 return response, 201
61
62 return wrapper
63
64 class Views(View):
65 decorators = [decorate_status_code]
66 methods = ["GET"]
67
68 async def dispatch_request(
69 self, *args: Any, **kwargs: Any
70 ) -> ResponseReturnValue:
71 return request.method
72
73 app.add_url_rule("/", view_func=Views.as_view("simple"))
74
75 test_client = app.test_client()
76 response = await test_client.get("/")
77 assert response.status_code == 201

Callers

nothing calls this directly

Calls 3

as_viewMethod · 0.80
test_clientMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…