Hi all,<br>I am fairly new to mock and I would like to know how to fix an issue during module imports and scope of functions.<br>Here is a snippet that explain problem I am dealing with:<br><br>from mock import MagicMock<br>
import sys<br>sys.func = lambda: 'x'<br>from sys import func<br>print func()<br># outputs 'x'<br>sys.func = MagicMock(return_value='mocked_x')<br>print func()<br># outputs 'x', it is not mocked<br>
<br>How could I fix this?<br><br>Thanks,<br>Mat<br>