[issue25690] Replacement for unittest.mock.mock_open

2016-03-15 Thread Niv Ben-David
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

[issue25690] Replacement for unittest.mock.mock_open

2016-01-30 Thread Niv Ben-David
Niv Ben-David added the comment: Regarding the documentation changes, my version simply mocks `open` more "closely", so for the most part I can't think of any changes to the documentation. I've added a bit about the mock object acting as a map of file names to mock o

[issue25690] Replacement for unittest.mock.mock_open

2015-11-21 Thread Niv Ben-David
New submission from Niv Ben-David: The unittest.mock module defines a mock_open utility to mock the builtin open function. During a recent project I found I needed something more. Specifically, mocking different files at the same time, better mocking for operations (like seek, readlines, etc