Skip to content

Releases: nivbend/mock-open

v1.4.0

15 Apr 15:37
Compare
Choose a tag to compare

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 builtin open 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 builtin open 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

23 Nov 08:23
Compare
Choose a tag to compare

Changed

  • Added TravisCI integration.

Fixed

  • Issue #7: Side effect now returns unittest.mock.DEFAULT.
  • Fixed compatibility issue with AsyncMock changes in 3.8.

v1.3.1

11 May 07:13
Compare
Choose a tag to compare

Fixed

  • Issue #5: Uploaded a new version to PyPi, identical to 1.3.0 functionality-wise.

v1.3.0

21 Nov 16:39
Compare
Choose a tag to compare

Update

Submitted as a patch to python.

Changed

  • Used mock wrapping for file operations (seek, read, etc.) instead of side_effect. Now there's no need to use contrived workarounds to add a side_effect to a mock. Also, setting return_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.

Fixed

  • Issue #3: Reset file's position after open.
  • Issue #4: Consecutive with open logging as children of call() in mock_open.mock_calls (instead of just call).
  • Replaced "" strings to the more python-esque ''.

v1.2.2

22 Aug 19:35
Compare
Choose a tag to compare

Fixed

  • Issues: #2.

v1.2.1

22 Aug 18:55
Compare
Choose a tag to compare

Fixed

  • Issues: #1.

v1.2.0

22 Aug 16:33
Compare
Choose a tag to compare

Changed

  • Use the standard unittest.mock library in python 3.3+ and the backport in earlier versions.

v1.1.0

17 Aug 19:26
Compare
Choose a tag to compare

Added

  • tox configuration.
  • Support for python 3.2 and 3.3 (along with 2.7 and 3.4).

Removed

  • The change log file (we use GitHub's releases).

Fixed

  • The .version file wasn't bundled with the package.

v1.0.1

17 Aug 17:55
Compare
Choose a tag to compare

Added

  • Project documentation and a change log.

v1.0.0

17 Aug 15:20
Compare
Choose a tag to compare

Added

  • The MockOpen class.