Python returns MagicMock object instead of return_value : <p>I have a python file <code>a.py</code> which contains two classes <code>A</code> and <code>B</code>.</p>

<pre><code>class A(object):
    def method_a(self):
        return "Class A method a"

class B(object):
    def method_b(self):
        a = A()
        print a.method_a()
</code></pre>

<p>I would like to unittest <code>method_b</code> in class <code>B</code> by mocking <code>A</code>. Here is the content of the file <code>testa.py</code> for this purpose:</p>

<pre><code>import unittest
import mock
import a


class TestB(unittest.TestCase):

    @mock.patch('a.A')
    def test_method_b(self, mock_a):
        mock_a.method_a.return_value = 'Mocked A'
        b = a.B()
        b.method_b()


if __name__ == '__main__':
    unittest.main()
</code></pre>

<p>I expect to get <code>Mocked A</code> in the output. But what I get is:</p>

<pre><code>&lt;MagicMock name='A().method_a()' id='4326621392'&gt;
</code></pre>

<p>Where am I doing wrong?</p>
