title: How to test print statements?
body: <p>You want to write <code>unittest</code>-cases for a function like that:</p>
  
  <pre><code>def test_me(a):
      for b in c:
          print do_something(a,b)
  </code></pre>
  
  <p>At first I thought about just collecting the outputs of <code>do_something</code> in a string and then returning it, to print and test the whole output together. But it's not always convinient because such loops could cause your buffer string to get very big, depending on the circumstances. So what can you do to test the output, when it is printed and not returned?</p>