<div dir="ltr">Ok I just scrolled up in the page and found I should be checking for return_value in this way:<div><br></div><div>m_myc.return_value.my_func.assert_called_once_with(&#39;a&#39;,&#39;b&#39;)</div></div><div class="gmail_extra">

<br clear="all"><div><div dir="ltr">Javier Domingo Cansino<br>Research &amp; Development Junior Engineer<br>Fon Labs Workgroup, Getxo - Spain.</div></div>
<br><br><div class="gmail_quote">On Tue, Jan 28, 2014 at 1:47 PM, Javier Domingo <span dir="ltr">&lt;<a href="mailto:javier.domingo@fon.com" target="_blank">javier.domingo@fon.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">Hi,<div><br></div><div>I have been trying to do mocking with the letter number of mock objects possible and I recently found that I was having problems with mock object&#39;s methods.</div><div><br></div><div>


Lets say I patch a class such as this:</div><div><br></div><div>class MyC(object):</div><div>    def my_func():</div><div><br></div><div>I use it in another class with an import like this:</div><div><br></div><div>from my import MyC</div>


<div><br></div><div>def func1():</div><div>    myc = MyC()</div><div>    myc.my_func(&#39;a&#39;,&#39;b&#39;)</div><div><br></div><div>And I put this in my tests:</div><div><br></div><div>@patch(&#39;code.MyC&#39;, spec=myc.MyC)</div>


<div>class TestMyC(TestCase):</div><div>    def my_first_test(self, m_myc):</div><div>        func1()</div><div>        print m_myc.mock_calls</div><div>        m_myc.assert_called_once_with()</div><div>        m_myc.my_func.assert_called_once_with(&#39;a&#39;,&#39;b&#39;)</div>


<div><br></div><div>And the first assertion goes alright, but the second one doesn&#39;t. I thought it was due to creating an object from the class or something like that, but the print statement outputs:</div><div>[call(), call().my_func(u&#39;a&#39;, u&#39;b&#39;)]</div>


<div><br></div><div>Which is correct. Any idea on this?</div><div><br></div><div><div><div dir="ltr">Javier Domingo Cansino<br>Research &amp; Development Junior Engineer<br>Fon Labs Workgroup, Getxo - Spain.</div></div>
</div></div>
</blockquote></div><br></div>