jeudi 22 février 2018

How to get the arguments passed to various calls from call_args_list?

I'm trying to use call_args_list to get the arguments passed to a certain function when it is called multiple times. I'm using this:

call_args_list = mock.add_row.call_args_list

Then I get a list that looks like this: [call('A', []), call('B', []), call('C', ['err'])].

If I only want to check that the second call doesn't have an error in the second argument and the third does, I need to somehow access the items within the call. Does anyone know how can I peel these call objects to get the items inside?

Aucun commentaire:

Enregistrer un commentaire