QuickDevGuide

Home › Flask Framework

Testing Flask Apps — Flask Framework

Use pytest with the app factory. Fixtures create an app with test config and expose a client. Tool Use app.testclient() send requests: client.get, client.post(json=...) app.testclirunner() invoke flask CLI commands app.testrequestcontext() call code that needs request / urlfor client.sessiontransaction() read or modify the session in tests Run with pytest -q; add pytest-cov for coverage: pytest --cov=myapp.

Key Takeaways