ensure error while opening session pops context

errors will be handled by the app error handlers
closes #1538, closes #1528
This commit is contained in:
David Lord 2017-04-22 13:39:54 -07:00
parent f22da31e7f
commit 13754b6d11
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 29 additions and 1 deletions

View file

@ -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