Je suis en train d'utiliser assert_called_once_with de unittest.maquette https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.assert_called_once_with
Mais je veux vérifier si 2 instances d'objets ont été passés avec te attributs corrects.
Donc, à l'intérieur de la classe I surdéfini l' __eq__
func:
def __eq__(self, other):
return (
self.id == other.id
and self.users == other.users
)
Et dans le code que j'utilise comme ceci
mock_add_user.assert_called_once_with(context_fix, expected_user_obj1, expected_user_obj2, users)
Mais je reçois un message d'erreur et la teste garde en comparant les repr de l'instance, à l'instar de ce
<app.domain.model.load_md.Load object at 0x10cb7d7d0>
E AssertionError: Expected call: add_user(<app.infrastructure.context.Context object at 0x10cb7da50>, <app.domain.model.load_md.Load object at 0x10cb7d7d0>, <app.domain.model.load_md.Load object at 0x10cb7d550>, [1, 2, 3, 2])
E Actual call: add_user(<app.infrastructure.context.Context object at 0x10cb7da50>, <app.domain.model.load_md.Load object at 0x10ca7f5d0>, <app.domain.model.load_md.Load object at 0x10cd1e650>, [1, 2, 3, 2])
J'ai vraiment besoin d'un moyen d'affirmer si une instance d'un objet est passé en paramètre de la fonction avec les attributs corrects rempli.