thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

DevOps & Automation · Intermediate

Mocking

Replacing real dependencies in tests with controllable fake objects that simulate behavior and record interactions.

Definition

Mocks isolate the unit under test from networks, databases, and devices. In Python, unittest.mock provides Mock, MagicMock, and patch.

Example

@patch('requests.get') returns a fake response so a test runs without calling the real API.

Exam tip

Mocks make unit tests fast and deterministic; overuse can hide integration problems.

Related terms