I\'m writing some unit tests for my Flask web application and I\'m trying to test the differences in the response between a request made by an anonymous user and a logged in
Flask-Login looks for user_id in the session, you can set this in the tests using session_transaction:
with app.test_client() as c:
with c.session_transaction() as sess:
sess['user_id'] = 'myuserid'
sess['_fresh'] = True # https://flask-login.readthedocs.org/en/latest/#fresh-logins
resp = c.get('/someurl')
Where myuserid is the id of your user object.