[TIP] Mock and function namespace
matdrapeau at gmail.com
Thu Mar 15 11:30:11 PDT 2012
I am fairly new to mock and I would like to know how to fix an issue during
module imports and scope of functions.
Here is a snippet that explain problem I am dealing with:
from mock import MagicMock
sys.func = lambda: 'x'
from sys import func
# outputs 'x'
sys.func = MagicMock(return_value='mocked_x')
# outputs 'x', it is not mocked
How could I fix this?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python