<div dir="ltr"><div style>I have some guesses about this, which I elaborated on in:</div><a href="http://stackoverflow.com/a/15280350/1309332">http://stackoverflow.com/a/15280350/1309332</a><div><br></div><div style>But basically, it looks like the recursive calls to create_autospec() are slowing down on your mocked object (whatever it is).  ID recommend one of three approaches:</div>

<div style>1. Don&#39;t autospec.  Do you need it?</div><div style>2. Only autospec some important method within the complex object that you are replacing</div><div style>3. use instance=True to limit the depth of recursion of calls to create_autospec().  This may change behavior that you are depending upon, however.  Be careful, since you are essentially lying to mock.patch if you do this.</div>

<div style><br></div><div style>Good luck!</div><div style>-Dan W.</div><div><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Mar 6, 2013 at 12:00 PM,  <span dir="ltr">&lt;<a href="mailto:testing-in-python-request@lists.idyll.org" target="_blank">testing-in-python-request@lists.idyll.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send testing-in-python mailing list submissions to<br>
        <a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
or, via email, send a message with subject or body &#39;help&#39; to<br>
        <a href="mailto:testing-in-python-request@lists.idyll.org">testing-in-python-request@lists.idyll.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:testing-in-python-owner@lists.idyll.org">testing-in-python-owner@lists.idyll.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of testing-in-python digest...&quot;<br>
<br>Today&#39;s Topics:<br>
<br>
   1. Bug with nosetests? Adding a new case with autospec=True will<br>
      take 15 seconds (John Wong)<br>
<br><br>---------- Forwarded message ----------<br>From: John Wong &lt;<a href="mailto:gokoproject@gmail.com">gokoproject@gmail.com</a>&gt;<br>To: <a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>

Cc: <br>Date: Tue, 5 Mar 2013 22:57:29 -0500<br>Subject: [TIP] Bug with nosetests? Adding a new case with autospec=True will take 15 seconds<br>HI,<div><br></div><div>Thanks for all the help so far.</div><div><br></div><div>

Here is the repo: <a href="https://bitbucket.org/yeukhon/bitbucket-python-api/src/6e57e95d5d09/tests/small?at=default" target="_blank">https://bitbucket.org/yeukhon/bitbucket-python-api/src/6e57e95d5d09/tests/small?at=default</a></div>


<div><br></div><div>I have a base unit test class in base.py.  For test_bitbucket.py, I inherit from the base unit test class.</div><div>I want to add new test cases and classes to test_bitbucket.py While doing so, I discovered performance issue.</div>


<div><br></div><div>I ran `nosetests` inside tests/small and I am getting these mix results</div><div><br></div><div><br></div><div>Ran 18 tests in 14.523s        - autospec=True and test_account_creation exists</div><div>


<div><br></div></div><div>Ran 18 tests in 0.621s         - autospec=False and test_account_creation_exists</div><div><br></div><div><br></div><div>Ran 17 tests in 1.081s         - autospec=True and test_account_creation is deleted</div>


<div><br></div><div><div>Ran 17 tests in 0.090s         - autospec=False, and test_account_creation is deleted</div></div><div><br></div><div><br></div><div>I understand requests is a big library, but the performance hit is crazy, going from 1.1s to 14.5s with and without the new test class, respectively.</div>


<div><br></div><div>Interestingly, if we run test_bitbucket.py individually.</div><div><br></div><div><div>(bbpy)yeukhon@yeukhon-P5E-VM-DO:~/hg/bitbucket-python-api/tests/small$ nosetests test_bitbucket.py</div><div>...</div>


<div>----------------------------------------------------------------------</div><div>Ran 3 tests in 0.090s</div><div><br></div><div>OK</div></div><div><br></div><div><br></div><div>Pretty much the same with/without autospec on.</div>


<div><br></div><div>Any idea? I don&#39;t know enough about nosetests internal.</div><div><br></div><div>Thanks!</div><div><br></div><div>John</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></div></div></div>