NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Senior0 views

Have you worked with mocks (test doubles)?

Practice

AI answer

Yes. Mocks let you isolate the code under test from external dependencies—such as an API, database, or clock—and verify how the code interacts with them. In Python, I use unittest.mock (Mock, patch) or pytest with monkeypatch. For example, you can mock an HTTP call and check that it was made with the required parameters. I try not to mock internal implementation details unnecessarily: excessive mocking makes tests brittle.