Date: January 19th 2016
Last updated: January 19th 2016
The mock module provides a way to add resources to a test framework that may not be available. Perhaps the methods that will produce data for your particular method is being developed by another team. In the mean time you can use mocks to act as a placeholder for future resources. Also, if test resources were available they might return stochastic values, making testing difficult. Subsequently, mock adds functionality to the other testing modules, like unittest and pytest.
pip install mock
Setup mock object
from mock import Mock # instatiate Mock class myMock = Mock(name = "rays mock", return_value = 234) print myMock # Output # <Mock name='rays' id='140690518246736'> # create Mock object myObject = myMock() print myObject #Output # 234