mardi 27 novembre 2018

Why is mocking out zeep.Client not working?

I'm writing unit tests for a piece of code that uses zeep to access a SOAP API so I want to mock out zeep. In my actual code, it looks something like this:

from zeep import Client

def do_something():
    client = Client("...")

In my test, I'm doing this:

from unittest import mock

@mock.patch('zeep.Client')
def test_do_somethi(self, client):
    do_something()

The Client that the actual function is obtaining, is the actual zeep client and not my mock. I also tried:

@mock.patch('zeep.client.Client')

and the result was the same.

Any ideas why this isn't working?

Aucun commentaire:

Enregistrer un commentaire