If request.endpoint (or other URL matching behavior) is needed while loading the session, RequestContext.match_request() can be called manually.
()
| 4 | |
| 5 | |
| 6 | def 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 |
nothing calls this directly
no test coverage detected