forked from orbit-oss/flask
Session falls back to a dummy object now if secret_key is missing.
This makes it possible to still read-only access the empty session but requires the secret key to be set for write access. The error message raised explains that. This closes #10.
This commit is contained in:
parent
791cdb28f5
commit
5310fc3822
2 changed files with 34 additions and 3 deletions
|
|
@ -72,6 +72,20 @@ class BasicFunctionality(unittest.TestCase):
|
|||
assert c.post('/set', data={'value': '42'}).data == 'value set'
|
||||
assert c.get('/get').data == '42'
|
||||
|
||||
def test_missing_session(self):
|
||||
app = flask.Flask(__name__)
|
||||
def expect_exception(f, *args, **kwargs):
|
||||
try:
|
||||
f(*args, **kwargs)
|
||||
except RuntimeError, e:
|
||||
assert e.args and 'session is unavailable' in e.args[0]
|
||||
else:
|
||||
assert False, 'expected exception'
|
||||
with app.test_request_context():
|
||||
assert flask.session.get('missing_key') is None
|
||||
expect_exception(flask.session.__setitem__, 'foo', 42)
|
||||
expect_exception(flask.session.pop, 'foo')
|
||||
|
||||
def test_request_processing(self):
|
||||
app = flask.Flask(__name__)
|
||||
evts = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue