I am writing a test, where I create a constructor.
This constructor has one parameter, which I pass a Mock inside.
But except for this parameter, there is another function inside of the parameter and I'm not sure how to get the constructor to see it as a Mock.
Here's an easy example:
Class MyClass():
def __init__(self, var):
self._var = var
self._func = func()
# Other stuff, I actually care about and can easily check **
Now it's easy to handle the var
if I pass it as a parameter in the test:
def test_trying_mock(self):
var = MagicMock()
object = MyClass(var)
And the var line is handled. How can I make the constructor see func as mock and make it skip it to the part I actually wanna run and check?
Aucun commentaire:
Enregistrer un commentaire