mocking - Mock an object in a method that is not a parameter in python -
(i'm python newbie)
i looking at: mocking out objects , methods
and wondering if can replace object in python method not passed parameter, lets method this:
def mypymethod(param1) myresult = os.path.something return myresult
and wish test mypymethod wish os.path @ case return "yourmockresult" when call test method
anyway can this? thanks!!
you should use michael foord's mock module same.
from documentation:
>>> mock import mock >>> real = productionclass() >>> real.method = mock(return_value=3) >>> real.method(3, 4, 5, key='value') 3 >>> real.method.assert_called_with(3, 4, 5, key='value')
Comments
Post a Comment