This because Flask-Login
caching TESTING
or LOGIN_DISABLED
on init_app
(https://github.com/maxcountryman/flask-login/blob/master/flask_login.py#L164).
So if you create application and then set something in config then you config changes will ignored.
Better way use application factory with separated configs for production and tests, it also decrease probability get errors with not cleaned application state in tests.
The easiest way reinit login_manager
:
class TestCase(unittest.TestCase):
def setUp(self):
app.config['TESTING'] = True
app.login_manager.init_app(app)
self.client = webtest.TestApp(app)