Keploy as a Python testing framework
Keploy tests Python applications by recording real HTTP traffic and every downstream call the request triggered, then replaying both as assertions. You add no fixtures, no unittest.mock patches, and no test containers — Keploy runs your existing app and derives the suite from observed behaviour.
keploy record -c "python manage.py runserver"What Keploy gives a Python team
Any CPython service, unchanged
Keploy wraps the command you already run. Django, FastAPI, Flask, and Litestar all record identically, and WSGI versus ASGI makes no difference because capture happens below the interpreter.
- CPython 3.8 and above
- runserver, uvicorn, or gunicorn
- Sync and async views record the same way
- Middleware stacks execute in full
Why Python integration tests slow teams down
The friction is rarely the assertions. It is everything around them — spinning up dependencies, keeping mocks honest, and repairing tests after every refactor.
Testing Python: by hand, with pytest + unittest.mock, or with Keploy
pytest and unittest.mock start from your model of a dependency. Keploy starts from the response the dependency actually sent, so a mock cannot quietly drift from the API it stands in for.
Select any row for the full comparison, with code.
What you write for Python vs what Keploy records
All three produce the same assertion. Only the third still passes after the next refactor without anyone editing it.
Two fake classes exist only for this file. Both hard-code a payload shape that nothing verifies against the real Stripe or Postgres response.
Three testing libraries and a database fixture, and the Stripe body is still a hand-typed literal that will not change when Stripe does.
The mocks are the actual Postgres rows and the actual Stripe response. Re-recording after an upstream change updates both without editing a line.
Times are estimates for authoring one endpoint’s coverage from scratch, not measurements.
Python testing tools, compared
The options a team on Python actually reaches for, and where each one genuinely wins. Select a row for the full comparison.
Assessments reflect each tool’s documented behaviour, not benchmark measurements.
Record your Python app once, replay it forever
Keploy sits below your Python process at the network layer. It watches the calls your app already makes, then serves them back on replay so tests run with no dependencies attached.
Keploy records a GET call to /api/v1/orders/{id} on a Python service and captures the dependency calls it makes.
What Keploy mocks for Python, with zero config
7 of the 8 dependencies a typical Python service talks to are stubbed from the recording itself — no mock classes, no fixture files, no containers in CI.
- Auto-mocked
PostgreSQLView page
Postgres frontend/backend protocol under psycopg
- Auto-mocked
MySQLView page
MySQL wire protocol under mysqlclient / PyMySQL
- Auto-mocked
MongoDBView page
MongoDB wire protocol under PyMongo
- Auto-mocked
RedisView page
RESP under redis-py
- Auto-mocked
Apache KafkaView page
Kafka protocol under kafka-python / confluent-kafka
- Auto-mocked
gRPCView page
HTTP/2 framed calls from grpcio
- Outbound HTTPAuto-mocked
Outbound HTTP
Any requests, httpx, urllib3, or aiohttp call
- Partial
Celery brokers
Task enqueue over the broker protocol
Your first Python test suite in under five minutes
Every command below runs against your existing Python service. Nothing in your source tree changes.
1Install the Keploy CLI
A single binary — no pip package, and nothing added to requirements.txt.
curl -sSL https://keploy.io/install.sh | bash2Record your app
Pass your normal start command. Keploy runs it and captures both inbound requests and outbound calls.
keploy record -c "python manage.py runserver 8000"3Exercise the endpoints you care about
curl, HTTPie, your frontend, or an existing smoke script — every request becomes a test case with its mocks attached.
curl -X POST localhost:8000/orders/ord_1/confirm -H 'Content-Type: application/json' -d '{"payment_token":"tok_123"}'4Replay in CI
Replay serves the recorded dependency responses, so the job needs no Postgres or Redis service.
keploy test -c "python manage.py runserver 8000" --delay 10
Ready to try it on your own Python service?
Works with the rest of your Python stack
Keploy records at the network layer, so framework and driver choices inside your Python app do not change how it captures traffic.
Django
Recorded through the dev server or gunicorn — no test client needed.
FastAPI
ASGI apps record the same way; async drivers included.
Flask
Wrap flask run and record; blueprints make no difference.
SQLAlchemy
Captured as the SQL it emits, not as ORM method calls.
Celery
Task enqueues are visible as broker traffic on the recording.
Poetry
Nothing to add to pyproject.toml — Keploy is a CLI, not a dependency.
Testing the rest of your stack
- Frameworks
Keploy as a Django testing framework
No test database to create and destroy, no fixtures to load — Keploy records your Django app serving real requests and replays the ORM queries it made.
Read the guide - Frameworks
Keploy as a FastAPI testing framework
Test FastAPI routes through the real ASGI server instead of TestClient, with async database calls mocked from the recording.
Read the guide - Databases
Keploy as a PostgreSQL testing framework
Record the Postgres frontend/backend protocol once and replay real result sets in tests — no container, no pg-mem, no schema to rebuild.
Read the guide - Caches & Stores
Keploy as a Redis testing framework
Record RESP traffic once and replay real cache hits, misses, TTLs, and pipeline responses without a Redis server in CI.
Read the guide - Databases
Keploy as a MongoDB testing framework
Mock MongoDB at the wire protocol — real documents, real BSON types, real aggregation results — without a mongod binary in CI.
Read the guide - Message Queues
Keploy as a Apache Kafka testing framework
Test producers and consumers against recorded broker exchanges — no embedded Kafka, no Testcontainers cluster, no flaky poll loops.
Read the guide
Join our GlobalCommunity
Connect with developers worldwide. Follow updates, ask questions, share feedback, and ship faster with other Keploy builders.
“Best report of integration and API tests I've seen — which we don't get from RestAssured.”
G2“Future of microservices testing. I don't write tests now!”
G2 · 5/5“An amazing product that simplifies the automation.”
Gartner · 4.0