[issue25690] Replacement for unittest.mock.mock_open

Niv Ben-David report at bugs.python.org
Tue Mar 15 15:54:15 EDT 2016


Niv Ben-David added the comment:

I copied the code in place of the old mock_open in unittest/mock.py.

Regarding the VFS issue, I think that it really depends on what you're trying to test. If you only care about "side effects" on the file system, the VFS way it much better and easier. But if you want to test the way files are handled by your code (proper handling of errors during open/read/write seems the obvious thing here, but I can think of other use cases), then I think MockOpen is the better tool.

----------
Added file: http://bugs.python.org/file42175/mock_open.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25690>
_______________________________________


More information about the Python-bugs-list mailing list