I have problems with understanding mock library in python. Here is example: A have two files test.py and another.py
test.py
#!
from mock import patch
from another import C
class A(object):
def method(self):
return 2
@patch('another.C')
@patch('test.A')
class TestB(object):
def test1(self, mA, mC):
print mA, A
print mC, C
another.py
class C(object):
def a(self):
return 3
So, question is "Why A have in output:
<MagicMock name='A' id='13985040'> <MagicMock name='A' id='13985040'>
<MagicMock name='C' id='13993936'> <class 'another.C'>
Why class from another.py can't be patched? In my case I have heavy function to test, and it imports classes from other files. So I cant understand how to them right.
Thanks