title: in python how to mock only the file write but not the file read?
body: <p>I am testing a function in which both </p>
  
  <pre><code>def foo():
      with open('input.dat', 'r') as f:
          ....
      with open('output.dat', 'w') as f:
          ....
  </code></pre>
  
  <p>are used. But I only want to mock the write part. Is it possible to do that? Or some other strategy should be used for testing such a function?</p>
  
  <pre><code>with patch('__builtin__.open') as m:
      foo()
  </code></pre>
  
  <p>would fail to read the data.</p>
  
  <p>Thanks in advance.</p>