title: Testing functions printing behavior
body: <p>I have a function foo(..) which prints a lot of messages using 'print'. I want to write unit test to test correctness of printed messages. How can I get printed messages instead of printing it in console. </p>
  
  <p>For example </p>
  
  <pre><code>def foo(x):
      print("Value is ", x)
  
  assertEqual(OUTPUT(foo(5)), "Value is 5")
  </code></pre>