I am testing a function in which both
def foo():
with open('input.dat', 'r') as f:
....
with open('output.dat', 'w') as f:
....
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?
with patch('__builtin__.open') as m:
foo()
would fail to read the data.
Thanks in advance.