lundi 22 février 2016

How to mock a singleton class method

Suppose we have the following structure:

class A():
    class __B():
        def to_be_mocked(self):
            #something here

Now we want to mock the function to_be_mocked.How can we mock it as the target accepted by mock.patch.object is package.module.ClassName.I have tried all methods like

target = A.__B
target = A.___B

and many more.

Aucun commentaire:

Enregistrer un commentaire