title: How to test that a function is called within a function with nosetests
body: <p>I'm trying to set up some automatic unit testing for a project. I have some functions which, as a side effect occasionally call another function. I want to write a unit test which tests that the second function gets called but I'm stumped. Below is pseudocode example:</p>
  
  <pre><code>def a(self):
      data = self.get()
      if len(data) &gt; 3500:
          self.b()
  
      # Bunch of other magic, which is easy to test.
  
  def b(self):
      serial.write("\x00\x01\x02")
  </code></pre>
  
  <p>How do I test that <code>b()</code>-gets called? </p>