Mocking
unittest.mock for isolation
Interview Relevant: Unit testing
Mocking
Replace real objects with mocks.
Code Examples
python
1from unittest.mock import MagicMock
2
3# Mock an object
4m = MagicMock()
5m.method.return_value = 10
6print(m.method()) # 10