forked from orbit-oss/flask
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:
parent
f22da31e7f
commit
13754b6d11
3 changed files with 29 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue