How to test session in flask resource

前端 未结 1 434
轮回少年
轮回少年 2021-02-19 00:43

I\'d like to test a resource. The response of that depends on a parameter in session (logged) To test this resource, I\'ve wrote those tests:

import app
import u         


        
1条回答
  •  借酒劲吻你
    2021-02-19 01:25

    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.

    0 讨论(0)
提交回复
热议问题