title: How to test a console print with pytest and python?
body: <p>I would like to test the print of a function with unitest on python 2.7 :</p>
  <p>Example:</p>
  <pre><code>def load_parse_xml(data_file):
      if os.path.isfile(data_file):
          print &quot;Parsing...&quot;
          data_parse = ET.ElementTree(file=data_file)
          return data_parse.getroot()
      else:
          print data_file + &quot; --&gt; File not exist&quot;
  </code></pre>
  <p>In the example I want to test that we have &quot;Parsing ...&quot; in the console</p>
  <p>here is my test:</p>
  <pre><code>def test_load_parse_xml(self):
      data_file = os.getcwd() + &quot;/xml_tests/xmltest.xml&quot;
      load_parse_xml(data_file)
      .......
  </code></pre>
  <p>But then I don't know how to test what is written &quot;Parsing ...&quot; in the console. I am blocked!</p>
  <p>I just want to test if we have the same message in the console as &quot;Parsing ...&quot;</p>