Browse Source

Merge pull request #309 from embe/master

Fix session loading in flask.testing.TestClient.session_transaction()
pull/303/merge
Armin Ronacher 13 years ago
parent
commit
7b899c8510
  1. 2
      flask/testing.py
  2. 3
      flask/testsuite/testing.py

2
flask/testing.py

@ -59,7 +59,7 @@ class FlaskClient(Client):
raise RuntimeError('Session transactions only make sense ' raise RuntimeError('Session transactions only make sense '
'with cookies enabled.') 'with cookies enabled.')
app = self.application app = self.application
environ_overrides = kwargs.pop('environ_overrides', {}) environ_overrides = kwargs.setdefault('environ_overrides', {})
self.cookie_jar.inject_wsgi(environ_overrides) self.cookie_jar.inject_wsgi(environ_overrides)
outer_reqctx = _request_ctx_stack.top outer_reqctx = _request_ctx_stack.top
with app.test_request_context(*args, **kwargs) as c: with app.test_request_context(*args, **kwargs) as c:

3
flask/testsuite/testing.py

@ -62,6 +62,9 @@ class TestToolsTestCase(FlaskTestCase):
self.assert_equal(len(sess), 1) self.assert_equal(len(sess), 1)
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.data, '[42]') self.assert_equal(rv.data, '[42]')
with c.session_transaction() as sess:
self.assert_equal(len(sess), 1)
self.assert_equal(sess['foo'], [42])
def test_session_transactions_no_null_sessions(self): def test_session_transactions_no_null_sessions(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)

Loading…
Cancel
Save