I have some Django models I need some unit test coverage on and in doing so I mock out some instances of them. Here is an example class I want coverage of
class MyMixin(object):
@property
def sum(self):
return field_one + field_two + field_three
class MyModel(Model, MyMixin):
field_one = IntegerField()
field_two = IntegerField()
field_three = IntegerField()
So I can mock out an instance of it like so:
mock_inst = mock.Mock(spec=MyModel, field_one=1, field_two=2, field_3=3)
However when I go to execute mock_inst.sum
, it doesn't execute the code properly, it gives me something from the mock class. Shouldn't it execute the code given the spec in the instance?
Aucun commentaire:
Enregistrer un commentaire