Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add test to testsuite/helpers.py #474

Closed
wants to merge 1 commit into from

1 participant

Alex Vykalyuk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 0 deletions.
  1. +25 −0 flask/testsuite/helpers.py
25 flask/testsuite/helpers.py
View
@@ -18,6 +18,7 @@
from StringIO import StringIO
from flask.testsuite import FlaskTestCase, catch_warnings, catch_stderr
from werkzeug.http import parse_cache_control_header, parse_options_header
+from flask.sessions import SecureCookieSessionInterface, SecureCookieSession
def has_encoding(name):
@@ -131,6 +132,30 @@ def index():
test_modified_url_encoding = None
+class FlashTestCase(FlaskTestCase):
+
+ def test_flashes_using_session_on_external_storage(self):
+ app = flask.Flask(__name__)
+ app.secret_key = 'testkey'
+
+ class MySecureCookieSession(SecureCookieSession):
+ def setdefault(self, key, value):
+ # If session implementation is not default, It might be
+ # not based on a dict => Doesn't have this method
+ raise AttributeError
+
+ class MySessionInterface(SecureCookieSessionInterface):
+ session_class = MySecureCookieSession
+
+ app.session_interface = MySessionInterface()
+
+ with app.test_request_context():
+ self.assert_(not flask.session.modified)
+ flask.flash('Fizz')
+ self.assert_(flask.session.modified)
+ self.assert_equal(list(flask.get_flashed_messages()), ['Fizz'])
+
+
class SendfileTestCase(FlaskTestCase):
def test_send_file_regular(self):
Something went wrong with that request. Please try again.