0PricingLogin
Flask Academy · Lesson

The Test Client and Fixtures

Spin up an app and client for tests.

Why Test Your Flask App

Tests let you change code without fear. With pytest you can prove every route still works in seconds, instead of clicking through your app by hand. 🧪

Meet the Test Client

Flask ships a fake browser called the test client. It calls your routes in memory, with no real server or network involved.

client = app.test_client()
resp = client.get('/')

All lessons in this course

  1. The Test Client and Fixtures
  2. Assert on Routes and JSON
  3. Isolate Tests with a Test Database
  4. Test Authenticated Endpoints
← Back to Flask Academy