diff options
author | Chris Withers <chris@withers.org> | 2019-05-02 09:02:53 +0100 |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2019-05-02 09:02:53 +0100 |
commit | ac1cc209d0d0dade6dac23dd7e24de7ee6bda4b4 (patch) | |
tree | 7f715c4fc1b72a9c99b6c31852d6ffa08c05568f | |
parent | ed446fa21c4658ca17771b63550ef5442ef31e60 (diff) | |
download | mock-ac1cc209d0d0dade6dac23dd7e24de7ee6bda4b4.tar.gz |
Preparing for 3.0.0 release.
23 files changed, 78 insertions, 48 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8716d70..e2fb72b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,80 @@ +3.0.0 +----- + +- Issue #35226: Recursively check arguments when testing for equality of + :class:`unittest.mock.call` objects and add note that tracking of + parameters used to create ancestors of mocks in ``mock_calls`` is not + possible. + +- Issue #31177: Fix bug that prevented using :meth:`reset_mock + <unittest.mock.Mock.reset_mock>` on mock instances with deleted attributes + +- Issue #26704: Added test demonstrating double-patching of an instance + method. Patch by Anthony Sottile. + +- Issue #35500: Write expected and actual call parameters on separate lines + in :meth:`unittest.mock.Mock.assert_called_with` assertion errors. + Contributed by Susan Su. + +- Issue #35330: When a :class:`Mock` instance was used to wrap an object, if + `side_effect` is used in one of the mocks of it methods, don't call the + original implementation and return the result of using the side effect the + same way that it is done with return_value. + +- Issue #30541: Add new function to seal a mock and prevent the + automatically creation of child mocks. Patch by Mario Corchero. + +- Issue #35022: :class:`unittest.mock.MagicMock` now supports the + ``__fspath__`` method (from :class:`os.PathLike`). + +- Issue #33516: :class:`unittest.mock.MagicMock` now supports the + ``__round__`` magic method. + +- Issue #35512: :func:`unittest.mock.patch.dict` used as a decorator with + string target resolves the target during function call instead of during + decorator construction. Patch by Karthikeyan Singaravelan. + +- Issue #36366: Calling ``stop()`` on an unstarted or stopped + :func:`unittest.mock.patch` object will now return `None` instead of + raising :exc:`RuntimeError`, making the method idempotent. Patch + byKarthikeyan Singaravelan. + +- Issue #35357: Internal attributes' names of unittest.mock._Call and + unittest.mock.MagicProxy (name, parent & from_kall) are now prefixed with + _mock_ in order to prevent clashes with widely used object attributes. + Fixed minor typo in test function name. + +- Issue #20239: Allow repeated assignment deletion of + :class:`unittest.mock.Mock` attributes. Patch by Pablo Galindo. + +- Issue #35082: Don't return deleted attributes when calling dir on a + :class:`unittest.mock.Mock`. + +- Issue #0: Improved an error message when mock assert_has_calls fails. + +- Issue #23078: Add support for :func:`classmethod` and :func:`staticmethod` + to :func:`unittest.mock.create_autospec`. Initial patch by Felipe Ochoa. + +- Issue #21478: Calls to a child function created with + :func:`unittest.mock.create_autospec` should propagate to the parent. + Patch by Karthikeyan Singaravelan. + +- Issue #36598: Fix ``isinstance`` check for Mock objects with spec when the + code is executed under tracing. Patch by Karthikeyan Singaravelan. + +- Issue #32933: :func:`unittest.mock.mock_open` now supports iteration over + the file contents. Patch by Tony Flury. + +- Issue #21269: Add ``args`` and ``kwargs`` properties to mock call objects. + Contributed by Kumar Akshay. + +- Issue #17185: Set ``__signature__`` on mock for :mod:`inspect` to get + signature. Patch by Karthikeyan Singaravelan. + +- Issue #35047: ``unittest.mock`` now includes mock calls in exception + messages if ``assert_not_called``, ``assert_called_once``, or + ``assert_called_once_with`` fails. Patch by Petter Strandmark. + - Issue #28380: unittest.mock Mock autospec functions now properly support assert_called, assert_not_called, and assert_called_once. diff --git a/NEWS.d/2017-10-17-12-04-37.bpo-30541.q3BM6C.rst b/NEWS.d/2017-10-17-12-04-37.bpo-30541.q3BM6C.rst deleted file mode 100644 index 7eb5e16..0000000 --- a/NEWS.d/2017-10-17-12-04-37.bpo-30541.q3BM6C.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add new function to seal a mock and prevent the automatically creation of -child mocks. Patch by Mario Corchero. diff --git a/NEWS.d/2018-04-30-22-43-31.bpo-32933.M3iI_y.rst b/NEWS.d/2018-04-30-22-43-31.bpo-32933.M3iI_y.rst deleted file mode 100644 index 4de7a8f..0000000 --- a/NEWS.d/2018-04-30-22-43-31.bpo-32933.M3iI_y.rst +++ /dev/null @@ -1,2 +0,0 @@ -:func:`unittest.mock.mock_open` now supports iteration over the file -contents. Patch by Tony Flury. diff --git a/NEWS.d/2018-05-15-17-06-42.bpo-33516.ZzARe4.rst b/NEWS.d/2018-05-15-17-06-42.bpo-33516.ZzARe4.rst deleted file mode 100644 index 77b1428..0000000 --- a/NEWS.d/2018-05-15-17-06-42.bpo-33516.ZzARe4.rst +++ /dev/null @@ -1 +0,0 @@ -:class:`unittest.mock.MagicMock` now supports the ``__round__`` magic method. diff --git a/NEWS.d/2018-07-10-18-53-46.bpo-0.UBQJBc.rst b/NEWS.d/2018-07-10-18-53-46.bpo-0.UBQJBc.rst deleted file mode 100644 index 9d82677..0000000 --- a/NEWS.d/2018-07-10-18-53-46.bpo-0.UBQJBc.rst +++ /dev/null @@ -1 +0,0 @@ -Improved an error message when mock assert_has_calls fails. diff --git a/NEWS.d/2018-09-14-10-38-18.bpo-31177.Sv91TN.rst b/NEWS.d/2018-09-14-10-38-18.bpo-31177.Sv91TN.rst deleted file mode 100644 index f385571..0000000 --- a/NEWS.d/2018-09-14-10-38-18.bpo-31177.Sv91TN.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix bug that prevented using :meth:`reset_mock <unittest.mock.Mock.reset_mock>` -on mock instances with deleted attributes diff --git a/NEWS.d/2018-10-18-17-57-28.bpo-35022.KeEF4T.rst b/NEWS.d/2018-10-18-17-57-28.bpo-35022.KeEF4T.rst deleted file mode 100644 index 426be70..0000000 --- a/NEWS.d/2018-10-18-17-57-28.bpo-35022.KeEF4T.rst +++ /dev/null @@ -1,2 +0,0 @@ -:class:`unittest.mock.MagicMock` now supports the ``__fspath__`` method -(from :class:`os.PathLike`). diff --git a/NEWS.d/2018-10-25-09-59-00.bpo-35047.abbaa.rst b/NEWS.d/2018-10-25-09-59-00.bpo-35047.abbaa.rst deleted file mode 100644 index 12eda27..0000000 --- a/NEWS.d/2018-10-25-09-59-00.bpo-35047.abbaa.rst +++ /dev/null @@ -1,3 +0,0 @@ -``unittest.mock`` now includes mock calls in exception messages if -``assert_not_called``, ``assert_called_once``, or ``assert_called_once_with`` -fails. Patch by Petter Strandmark.
\ No newline at end of file diff --git a/NEWS.d/2018-10-27-11-54-12.bpo-35082.HDj1nr.rst b/NEWS.d/2018-10-27-11-54-12.bpo-35082.HDj1nr.rst deleted file mode 100644 index 45a0729..0000000 --- a/NEWS.d/2018-10-27-11-54-12.bpo-35082.HDj1nr.rst +++ /dev/null @@ -1,2 +0,0 @@ -Don't return deleted attributes when calling dir on a -:class:`unittest.mock.Mock`. diff --git a/NEWS.d/2018-11-15-07-14-32.bpo-35226.wJPEEe.rst b/NEWS.d/2018-11-15-07-14-32.bpo-35226.wJPEEe.rst deleted file mode 100644 index b95cc97..0000000 --- a/NEWS.d/2018-11-15-07-14-32.bpo-35226.wJPEEe.rst +++ /dev/null @@ -1,3 +0,0 @@ -Recursively check arguments when testing for equality of -:class:`unittest.mock.call` objects and add note that tracking of parameters -used to create ancestors of mocks in ``mock_calls`` is not possible. diff --git a/NEWS.d/2018-12-03-21-20-24.bpo-35357.rhhoiC.rst b/NEWS.d/2018-12-03-21-20-24.bpo-35357.rhhoiC.rst deleted file mode 100644 index 1dade5b..0000000 --- a/NEWS.d/2018-12-03-21-20-24.bpo-35357.rhhoiC.rst +++ /dev/null @@ -1,4 +0,0 @@ -Internal attributes' names of unittest.mock._Call and -unittest.mock.MagicProxy (name, parent & from_kall) are now prefixed with -_mock_ in order to prevent clashes with widely used object attributes. -Fixed minor typo in test function name. diff --git a/NEWS.d/2018-12-06-00-43-13.bpo-35330.abB4BN.rst b/NEWS.d/2018-12-06-00-43-13.bpo-35330.abB4BN.rst deleted file mode 100644 index 24d0ab8..0000000 --- a/NEWS.d/2018-12-06-00-43-13.bpo-35330.abB4BN.rst +++ /dev/null @@ -1,4 +0,0 @@ -When a :class:`Mock` instance was used to wrap an object, if `side_effect` -is used in one of the mocks of it methods, don't call the original -implementation and return the result of using the side effect the same way -that it is done with return_value. diff --git a/NEWS.d/2018-12-09-17-04-15.bpo-17185.SfSCJF.rst b/NEWS.d/2018-12-09-17-04-15.bpo-17185.SfSCJF.rst deleted file mode 100644 index 311c6d2..0000000 --- a/NEWS.d/2018-12-09-17-04-15.bpo-17185.SfSCJF.rst +++ /dev/null @@ -1,2 +0,0 @@ -Set ``__signature__`` on mock for :mod:`inspect` to get signature. -Patch by Karthikeyan Singaravelan. diff --git a/NEWS.d/2018-12-09-21-35-49.bpo-20239.V4mWBL.rst b/NEWS.d/2018-12-09-21-35-49.bpo-20239.V4mWBL.rst deleted file mode 100644 index fe9c69d..0000000 --- a/NEWS.d/2018-12-09-21-35-49.bpo-20239.V4mWBL.rst +++ /dev/null @@ -1,2 +0,0 @@ -Allow repeated assignment deletion of :class:`unittest.mock.Mock` attributes. -Patch by Pablo Galindo. diff --git a/NEWS.d/2018-12-10-13-18-37.bpo-26704.DBAN4c.rst b/NEWS.d/2018-12-10-13-18-37.bpo-26704.DBAN4c.rst deleted file mode 100644 index 458f495..0000000 --- a/NEWS.d/2018-12-10-13-18-37.bpo-26704.DBAN4c.rst +++ /dev/null @@ -1,2 +0,0 @@ -Added test demonstrating double-patching of an instance method. Patch by -Anthony Sottile. diff --git a/NEWS.d/2018-12-21-09-54-30.bpo-21478.5gsXtc.rst b/NEWS.d/2018-12-21-09-54-30.bpo-21478.5gsXtc.rst deleted file mode 100644 index 1000748..0000000 --- a/NEWS.d/2018-12-21-09-54-30.bpo-21478.5gsXtc.rst +++ /dev/null @@ -1,2 +0,0 @@ -Calls to a child function created with :func:`unittest.mock.create_autospec` -should propagate to the parent. Patch by Karthikeyan Singaravelan. diff --git a/NEWS.d/2019-01-18-23-10-10.bpo-23078.l4dFoj.rst b/NEWS.d/2019-01-18-23-10-10.bpo-23078.l4dFoj.rst deleted file mode 100644 index 975cc9c..0000000 --- a/NEWS.d/2019-01-18-23-10-10.bpo-23078.l4dFoj.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add support for :func:`classmethod` and :func:`staticmethod` to -:func:`unittest.mock.create_autospec`. Initial patch by Felipe Ochoa. diff --git a/NEWS.d/2019-02-10-00-00-13.bpo-35500.1HOMmo.rst b/NEWS.d/2019-02-10-00-00-13.bpo-35500.1HOMmo.rst deleted file mode 100644 index 16b0fbf..0000000 --- a/NEWS.d/2019-02-10-00-00-13.bpo-35500.1HOMmo.rst +++ /dev/null @@ -1 +0,0 @@ -Write expected and actual call parameters on separate lines in :meth:`unittest.mock.Mock.assert_called_with` assertion errors. Contributed by Susan Su. diff --git a/NEWS.d/2019-02-10-16-49-16.bpo-21269.Fqi7VH.rst b/NEWS.d/2019-02-10-16-49-16.bpo-21269.Fqi7VH.rst deleted file mode 100644 index 15ad636..0000000 --- a/NEWS.d/2019-02-10-16-49-16.bpo-21269.Fqi7VH.rst +++ /dev/null @@ -1 +0,0 @@ -Add ``args`` and ``kwargs`` properties to mock call objects. Contributed by Kumar Akshay. diff --git a/NEWS.d/2019-02-24-00-04-10.bpo-35512.eWDjCJ.rst b/NEWS.d/2019-02-24-00-04-10.bpo-35512.eWDjCJ.rst deleted file mode 100644 index 8281b1b..0000000 --- a/NEWS.d/2019-02-24-00-04-10.bpo-35512.eWDjCJ.rst +++ /dev/null @@ -1,3 +0,0 @@ -:func:`unittest.mock.patch.dict` used as a decorator with string target -resolves the target during function call instead of during decorator -construction. Patch by Karthikeyan Singaravelan. diff --git a/NEWS.d/2019-03-20-15-13-18.bpo-36366.n0eav_.rst b/NEWS.d/2019-03-20-15-13-18.bpo-36366.n0eav_.rst deleted file mode 100644 index a435048..0000000 --- a/NEWS.d/2019-03-20-15-13-18.bpo-36366.n0eav_.rst +++ /dev/null @@ -1,4 +0,0 @@ -Calling ``stop()`` on an unstarted or stopped :func:`unittest.mock.patch` -object will now return `None` instead of raising :exc:`RuntimeError`, -making the method idempotent. -Patch byKarthikeyan Singaravelan. diff --git a/NEWS.d/2019-04-11-22-11-24.bpo-36598.hfzDUl.rst b/NEWS.d/2019-04-11-22-11-24.bpo-36598.hfzDUl.rst deleted file mode 100644 index 2a79802..0000000 --- a/NEWS.d/2019-04-11-22-11-24.bpo-36598.hfzDUl.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix ``isinstance`` check for Mock objects with spec when the code is -executed under tracing. Patch by Karthikeyan Singaravelan. diff --git a/mock/mock.py b/mock/mock.py index 37ea1ad..12ec7bf 100644 --- a/mock/mock.py +++ b/mock/mock.py @@ -68,7 +68,7 @@ from unittest.util import safe_repr import six from six import wraps -__version__ = '2.0.0' +__version__ = '3.0.0' version_info = tuple(int(p) for p in __version__.split('.')) import mock |