<div dir="ltr">Instead of <span class="" style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:16.799999237060547px;white-space:pre;background-color:rgb(255,255,255)">mock</span><span class="" style="font-weight:bold;color:rgb(0,0,0);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:16.799999237060547px;white-space:pre;background-color:rgb(255,255,255)">.</span><span class="" style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:16.799999237060547px;white-space:pre;background-color:rgb(255,255,255)">patch</span><span class="" style="color:rgb(0,0,0);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:16.799999237060547px;white-space:pre">(</span><span class="" style="color:rgb(221,17,68);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:16.799999237060547px;white-space:pre">&#39;miners.tasks_utils.mechanize_url&#39;</span><span style="color:rgb(0,0,0);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:16.799999237060547px;white-space:pre">)</span> you should try <span class="" style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:16.799999237060547px;white-space:pre;background-color:rgb(255,255,255)">mock</span><span class="" style="font-weight:bold;color:rgb(0,0,0);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:16.799999237060547px;white-space:pre;background-color:rgb(255,255,255)">.</span><span class="" style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:16.799999237060547px;white-space:pre;background-color:rgb(255,255,255)">patch</span><span class="" style="color:rgb(0,0,0);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:16.799999237060547px;white-space:pre">(</span><span class="" style="color:rgb(221,17,68);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:16.799999237060547px;white-space:pre">&#39;twitter_profile.mechanize_url&#39;</span><span style="color:rgb(0,0,0);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:16.799999237060547px;white-space:pre">)</span>. <div>
<br></div><div>Once your twitter_profile module is imported it will have a reference to mechanize_url.  When you patch miners.tasks_utils you are not changing this reference.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Fri, Feb 7, 2014 at 10:42 AM, Mahdi Yusuf <span dir="ltr">&lt;<a href="mailto:yusuf.mahdi@gmail.com" target="_blank">yusuf.mahdi@gmail.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">I am at my wits end pretty much. I am not sure what is happening here. <div><br></div><div>I am unable to mock an import function. My code is <a href="https://gist.github.com/myusuf3/685083e70bf3f93fd43c" target="_blank">here</a>. After some reading I know you patch where the function is used not where its defined.</div>


<div><br></div><div>I have also tried everything else but the mechanize_url is till running as implemented in code not mocked in test.</div><div><br></div><div>Thoughts? </div><span class="HOEnZb"><font color="#888888"><div>
<br></div><div>-- <br><div>Mahdi Yusuf</div>


</div></font></span></div>
<br>_______________________________________________<br>
testing-in-python mailing list<br>
<a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>
<a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>David<br>blog: <a href="http://www.traceback.org" target="_blank">http://www.traceback.org</a><br>twitter: <a href="http://twitter.com/dstanek" target="_blank">http://twitter.com/dstanek</a><div>
www: <a href="http://dstanek.com" target="_blank">http://dstanek.com</a></div>
</div>