I have a python class with such a module:
xy.py
from a.b import ClassA
class ClassB:
def method_1():
a = ClassA()
a.method2()
then I have a ClassA defined as:
b.py
from c import ClassC
class ClassA:
def method2():
c = ClassC()
c.method3()
Now in this code when writing a test for xy.py I want mock.patch ClassC, is there any way to achieve this in python?
Obviously I tried:
mock.patch('a.b.ClassA.ClassC)
and
mock.patch('a.b.c.ClassC')
None of them worked.
Ankit source
share