jeudi 10 août 2017

in python how to mock only the file write but not the file read?

I am testing a function in which both

with open('f.dat', 'r') as f:
    ....
with open('f.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?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire