MCPcopy
hub / github.com/pallets/flask / test_view_inheritance

Function test_view_inheritance

tests/test_views.py:62–77  ·  view source on GitHub ↗
(app, client)

Source from the content-addressed store, hash-verified

60
61
62def test_view_inheritance(app, client):
63 class Index(flask.views.MethodView):
64 def get(self):
65 return "GET"
66
67 def post(self):
68 return "POST"
69
70 class BetterIndex(Index):
71 def delete(self):
72 return "DELETE"
73
74 app.add_url_rule("/", view_func=BetterIndex.as_view("index"))
75
76 meths = parse_set_header(client.open("/", method="OPTIONS").headers["Allow"])
77 assert sorted(meths) == ["DELETE", "GET", "HEAD", "OPTIONS", "POST"]
78
79
80def test_view_decorators(app, client):

Callers

nothing calls this directly

Calls 3

as_viewMethod · 0.80
openMethod · 0.80
add_url_ruleMethod · 0.45

Tested by

no test coverage detected