Skip to main content
Tests run against a separate test database, configured for you. Each test starts fresh:
1

Before each test

Tables are created.
2

After each test

Tables are dropped and the engine is disposed.
One test cannot affect another.

A fixture mistake that is easy to misread

Flask-Login caches the current user on g for the lifetime of an application context. A fixture that holds one app.app_context() open across requests from several test clients resolves every request to the first user loaded. Seed your data inside a context, then make requests outside it:
This one is easy to misdiagnose. The symptom is an authorization test that passes for the first user and fails for the second, with no visible difference between them.