|
|
|
@ -12,6 +12,7 @@
|
|
|
|
|
import pytest |
|
|
|
|
|
|
|
|
|
import flask |
|
|
|
|
from flask.sessions import SessionInterface |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
from greenlet import greenlet |
|
|
|
@ -193,3 +194,27 @@ def test_greenlet_context_copying_api():
|
|
|
|
|
|
|
|
|
|
result = greenlets[0].run() |
|
|
|
|
assert result == 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_session_error_pops_context(): |
|
|
|
|
class SessionError(Exception): |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
class FailingSessionInterface(SessionInterface): |
|
|
|
|
def open_session(self, app, request): |
|
|
|
|
raise SessionError() |
|
|
|
|
|
|
|
|
|
class CustomFlask(flask.Flask): |
|
|
|
|
session_interface = FailingSessionInterface() |
|
|
|
|
|
|
|
|
|
app = CustomFlask(__name__) |
|
|
|
|
|
|
|
|
|
@app.route('/') |
|
|
|
|
def index(): |
|
|
|
|
# shouldn't get here |
|
|
|
|
assert False |
|
|
|
|
|
|
|
|
|
response = app.test_client().get('/') |
|
|
|
|
assert response.status_code == 500 |
|
|
|
|
assert not flask.request |
|
|
|
|
assert not flask.current_app |
|
|
|
|