I know this question has been asked before, but I have a particular problem, meaning I want the mock_open to actually return a specific mock object.
I have a function I want to test:
def foo(src,dest):
with contextlib.nested(
open(src,'r'),
open(dest,'w')) as (src,dest):
d = src.read(1)
....
My question is, using mock_open(), how do I get it to return a specific src and dest mock, so I can make assertions on them? Even if I use mock_open(mock=mock_src) it still does not pass the object I want, but a new one.