Hi Damian,<br><br>To answer your first question, we ran into the trouble when mocking time.time().  This came up for us, as type(time.time) is 'builtin_function_or_method', which is the same as type(open) -> 'builtin_function_or_method'.<br>

<br>We also updated your adaptation to our patch so that no code is repeated.  This should make the function cleaner and more readable.  This new code can be found at: <a href="https://github.com/jacthinman/Tor-Stem/blob/mocking/test/mocking.py">https://github.com/jacthinman/Tor-Stem/blob/mocking/test/mocking.py</a><br>

<br>Best,<br>-Erik & Megan<br><br><div class="gmail_quote">On Wed, Jun 13, 2012 at 2:21 AM, Damian Johnson <span dir="ltr"><<a href="mailto:atagar@torproject.org" target="_blank">atagar@torproject.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Megan, thanks for the patch! What is an example of a standard<br>
library function with a builtin type? I'd like to exercise the use<br>
case that has been causing you trouble.<br>
<br>
This change has a couple issues, for instance it treats anything with<br>
the same name as a builtin like a builtin. It also calls setattr() on<br>
standard library functions if you try to mock it a second time.<br>
<br>
I've pushed an adaptation of your change to the 'mocking' branch of my<br>
personal repository...<br>
git://<a href="http://git.torproject.org/user/atagar/stem.git" target="_blank">git.torproject.org/user/atagar/stem.git</a><br>
<br>
change...<br>
<a href="https://gitweb.torproject.org/user/atagar/stem.git/commitdiff/5029e4b9b92dbacdfc49867b7dcbee230ca782a8" target="_blank">https://gitweb.torproject.org/user/atagar/stem.git/commitdiff/5029e4b9b92dbacdfc49867b7dcbee230ca782a8</a><br>


<br>
It shouldn't have the issues that I mentioned, though some remaining<br>
bits of the change confuse me. As you've found the mocking code is<br>
pretty tricky so I won't be able to make sense of it until I see what<br>
was breaking.<br>
<br>
Thanks! -Damian<br>
<br>
PS. Very nice commit message on b8b7c22. It helped me a lot in making<br>
sense of the change - thanks for that.<br>
</blockquote></div><br>