title: How can I unit test a recursive functions in python?
body: <p>I was wondering how can I unit test if a recursive function has been called correctly. For example this function:</p>
  <pre class="lang-py prettyprint-override"><code>def test01(number):
          if(len(number) == 1):
              return 1
          else:
              return 1+test01(number[1:])
  </code></pre>
  <p>It counts recursvely how many digits a number has (assuming the number type is string)
  So, I want to test if the function test01 has been called recursively. It would be ok if it is implemented just like that, but not if it is implemented as:</p>
  <pre><code>def test01(number):
      return len(number)
  </code></pre>
  <p><strong>EDIT:
  The recursive approach is mandatory for educational purposes, so the UnitTest process will automate programming exercises checking. Is there a way to check if the function was called more than once? If that is possible, I can have 2 tests, one asserting the correct output and one to check if the function was called more than once for the same input.</strong></p>
  <p>Thank you in advance for your help</p>