test_session_interface.py
This file
Path
tests/test_session_interface.py
27 lines · 771 bytes · Python
Last changed by
converters have access to sessionDavid Lordbefore adoptiona7b02b3
History of this fileTake it
1import flask2from flask.sessions import SessionInterface345def test_open_session_with_endpoint():6 """If request.endpoint (or other URL matching behavior) is needed7 while loading the session, RequestContext.match_request() can be8 called manually.9 """1011 class MySessionInterface(SessionInterface):12 def save_session(self, app, session, response):13 pass1415 def open_session(self, app, request):16 flask._request_ctx_stack.top.match_request()17 assert request.endpoint is not None1819 app = flask.Flask(__name__)20 app.session_interface = MySessionInterface()2122 @app.get("/")23 def index():24 return "Hello, World!"2526 response = app.test_client().get("/")27 assert response.status_code == 200