MCPcopy Create free account
hub / github.com/pallets/flask / test_open_session_with_endpoint

Function test_open_session_with_endpoint

tests/test_session_interface.py:6–28  ·  view source on GitHub ↗

If request.endpoint (or other URL matching behavior) is needed while loading the session, RequestContext.match_request() can be called manually.

()

Source from the content-addressed store, hash-verified

4
5
6def test_open_session_with_endpoint():
7 """If request.endpoint (or other URL matching behavior) is needed
8 while loading the session, RequestContext.match_request() can be
9 called manually.
10 """
11
12 class MySessionInterface(SessionInterface):
13 def save_session(self, app, session, response):
14 pass
15
16 def open_session(self, app, request):
17 request_ctx.match_request()
18 assert request.endpoint is not None
19
20 app = flask.Flask(__name__)
21 app.session_interface = MySessionInterface()
22
23 @app.get("/")
24 def index():
25 return "Hello, World!"
26
27 response = app.test_client().get("/")
28 assert response.status_code == 200

Callers

nothing calls this directly

Calls 3

test_clientMethod · 0.95
MySessionInterfaceClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected