title: How to do unit testing of functions writing files using Python's 'unittest'
body: <p>I have a Python function that writes an output file to disk.</p>
  <p>I want to write a unit test for it using Python's <code>unittest</code> module.</p>
  <p>How should I assert equality of files? I would like to get an error if the file content differs from the expected one + list of differences. As in the output of the Unix <a href="https://en.wikipedia.org/wiki/Diff" rel="noreferrer">diff</a> command.</p>
  <p>Is there an official or recommended way of doing that?</p>