mardi 29 mars 2016

assert_has_calls does not stub the method call

I'm using assert_has_calls from the mock python library. I'm running into a problem when I do something like this:

mocks = mock.Mock()
mocks.assert_has_calls([mock.call.method_to_be_mocked(mock.ANY),
                        mock.call.method_to_be_mocked(mock.ANY)])

I want to verify that the method is called a certain number of times, but at the same time I also want to stub out the calls to the method. assert_has_calls doesn't seem to do the stubbing part. The actual method is called and it fails in the dev environment.

What can I do to resolve this ?

Aucun commentaire:

Enregistrer un commentaire