title: Why is os.remove None after executing pytest?
body: <p>I create a LazyLoader class which downloads files from S3 to the local file system, but only if they were not downloaded before. This class deletes the stuff it downloaded once it gets destroyed:</p>
  
  <pre><code>def __del__(self):
      """Remove downloaded files when this object is deleted."""
      for downloaded_file in self.loaded_data.values():
          os.remove(downloaded_file)
  </code></pre>
  
  <p>The tests pass, but after pytest tells me that the tests passed I get:</p>
  
  <pre><code>Exception ignored in: &lt;bound method LazyLoader.__del__ of LazyLoader({})&gt;
  Traceback (most recent call last):
    File "my_lazy_loader.py", line 47, in __del__
  TypeError: 'NoneType' object is not callable
  </code></pre>
  
  <p>Line 47 is <code>os.remove(downloaded_file)</code>. So <code>os.remove is None</code> evaluates to <code>True</code>. Why? How can I fix that?</p>
  
  <p>If I move the code in <code>__del__</code> to a method <code>clean()</code>, I don't have that problem.</p>