From 4dc1796b1c09961098edc0aaac90a28be2b7fc9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bartoszkiewicz?= Date: Mon, 29 Aug 2011 21:37:52 +0200 Subject: [PATCH] Fixed session loading in flask.testing.TestClient.session_transaction() --- flask/testing.py | 2 +- flask/testsuite/testing.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/flask/testing.py b/flask/testing.py index 612b4d4d..757e20cc 100644 --- a/flask/testing.py +++ b/flask/testing.py @@ -57,7 +57,7 @@ class FlaskClient(Client): raise RuntimeError('Session transactions only make sense ' 'with cookies enabled.') app = self.application - environ_overrides = kwargs.pop('environ_overrides', {}) + environ_overrides = kwargs.setdefault('environ_overrides', {}) self.cookie_jar.inject_wsgi(environ_overrides) outer_reqctx = _request_ctx_stack.top with app.test_request_context(*args, **kwargs) as c: diff --git a/flask/testsuite/testing.py b/flask/testsuite/testing.py index 32867c3f..5ee147f9 100644 --- a/flask/testsuite/testing.py +++ b/flask/testsuite/testing.py @@ -59,6 +59,9 @@ class TestToolsTestCase(FlaskTestCase): self.assert_equal(len(sess), 1) rv = c.get('/') 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): app = flask.Flask(__name__)