<div dir="ltr">Thanks Very Much Paul.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 25, 2016 at 7:46 PM, Paul Moore <span dir="ltr"><<a href="mailto:p.f.moore@gmail.com" target="_blank">p.f.moore@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 25 August 2016 at 14:55, Sijo Jose <<a href="mailto:mailtosijojose@gmail.com">mailtosijojose@gmail.com</a>> wrote:<br>
> I've the following code in the __init__.py file<br>
><br>
> from time import sleep<br>
> from functools import wraps<br>
><br>
> def multi_try(func):<br>
> @wraps(func)<br>
> def inner(*args, **kwargs):<br>
> count = 0<br>
> while count < 5:<br>
> resp = func(*args, **kwargs)<br>
> if resp.status_code in [200, 201]:<br>
> return resp<br>
> sleep(1)<br>
> count += 1<br>
> return inner<br>
><br>
><br>
> While writing tests for the above decorator I'm not able to patch the the<br>
> *time.sleep* properly.<br>
<br>
</span>The code here uses "sleep" (a module variable in your module) not<br>
"time.sleep". So you need to patch "mymodule.sleep" rather than<br>
"time.sleep", or do "import time" and use "time.sleep" in your<br>
__init__.py.<br>
<span class="HOEnZb"><font color="#888888"><br>
Paul<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><font size="2" color="#3d85c6" face="garamond, serif"><i><b style="background-color:rgb(255,255,255)">Regards</b></i></font><div><font size="2" color="#3d85c6" face="garamond, serif"><i><b style="background-color:rgb(255,255,255)">Sijo Jose</b></i></font></div></div></div>
</div>