How to test session in flask resource
If you did not set a custom app.session_interface
, then you forgot to set a secret key:
def setUp(self): app.config['SECRET_KEY'] = 'sekrit!' self.app = app.app.test_client()
This just sets a mock secret key for the tests, but for your application to work you'll need to generate a production secret key, see the sessions section in the Quickstart documentation for tips on how to produce a good secret key.
Without a secret key, the default session implementation fails to create a session.