Explain it in 60 seconds
Mocking external services in tests
Data Engineering · Python · Intermediate
How do you test code that calls external APIs or databases without hitting them?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Use unittest.mock or pytest-mock to replace calls with fakes.
- Libraries like responses or requests-mock fake HTTP responses.
- Use moto to mock AWS services like S3.
- Test error paths, like timeouts and 429s.
- Keep a few integration tests against real test environments.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.