Say I have a class:
class A():
def f(self):
self._v = 1
Tried:
m=Mocker()
A.f._v = m.mock()
...
but didn't work. Not sure how...
Did you mean Mock library?
from mock import Mock
real = ProductionClass()
real.method = Mock(return_value=3)
real.method(3, 4, 5, key='value')
edit:
You are trying to access A.f._v before mocking which is impossible. Not sure what are you trying to do, but this will work
>>>A.f = Mock()
>>>a = A()
>>>a.f._v
<Mock name='mock._v' id='42076240'>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With