jeudi 24 septembre 2015

Correct path of mock.patch

I have a problem about figuring out paths when using mock in Python.

Suppose, that i have the following files

file1.py

def func1():
    return 'X'

file2.py

from file1 import func1

class ClassA():

    def func_that_uses_func1():
        x = func1()

How could I patch the usage of func1 on ClassA? I have tried @mock.patch(file2.func1), but i get an error because file2 doesn't have the attribute func1.

Aucun commentaire:

Enregistrer un commentaire