ImportError: No module named mock
unittest is a built-in module; mock is an external library (pre-3.3 betas, anyway). After installing mock via pip install, you import it not by using from unittest.mock import MagicMock but from mock import MagicMock Edit: mock has been included in the unittest module (since Python3.3), and can be imported by import unittest.mock.