Releases: nivbend/mock-open
Releases · nivbend/mock-open
v1.4.0
Changed
- Moved library code under the
src/
directory. - Copied over the original CPython's
unittest.mock.mock_open
tests (with some modifications) as part of the library's test suite. This brought up a few differences in the API and usage to light which were fixed as part of this release.
Fixed
- Allow to omit the
mode
argument, since the builtinopen
will understand this as'r'
. - Reset position in the file-like mock in consecutive calls to a patched
open
(either a direct call or when used as a context manager). - Define
FileLikeMock
as an iterator, which was an API of the builtinopen
it was missing:with patch('builtins.open', new_callable=MockOpen) as mock_open: mock_open.return_value.read_data = 'SOME DATA' with open('/some/path') as f: assert 'SOME DATA' == next(f)
v1.3.2
v1.3.1
v1.3.0
Update
Submitted as a patch to python.
Changed
- Used mock wrapping for file operations (
seek
,read
, etc.) instead ofside_effect
. Now there's no need to use contrived workarounds to add aside_effect
to a mock. Also, settingreturn_value
actually works! - Python 3: Opening files as binary creates (or changes to) a
BytesIO
to store contents. - Merged the issues' unit tests to the main testing module.