Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pytest-mock to 3.14.0 #803

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pyup-bot
Copy link
Collaborator

This PR updates pytest-mock from 1.6.3 to 3.14.0.

Changelog

3.14.0

-------------------

* `415 <https://github.com/pytest-dev/pytest-mock/pull/415>`_: ``MockType`` and ``AsyncMockType`` can be imported from ``pytest_mock`` for type annotation purposes.

* `420 <https://github.com/pytest-dev/pytest-mock/issues/420>`_: Fixed a regression which would cause ``mocker.patch.object`` to not being properly cleared between tests.

3.13.0

-------------------

* `417 <https://github.com/pytest-dev/pytest-mock/pull/417>`_: ``spy`` now has ``spy_return_list``, which is a list containing all the values returned by the spied function.
* ``pytest-mock`` now requires ``pytest>=6.2.5``.
* `410 <https://github.com/pytest-dev/pytest-mock/pull/410>`_: pytest-mock's ``setup.py`` file is removed.
If you relied on this file, e.g. to install pytest using ``setup.py install``,
please see `Why you shouldn't invoke setup.py directly <https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html#summary>`_ for alternatives.

3.12.0

-------------------

* Added support for Python 3.12.
* Dropped support for EOL Python 3.7.
* ``mocker.resetall()`` now also resets mocks created by ``mocker.create_autospec`` (`390`_).

.. _390: https://github.com/pytest-dev/pytest-mock/pull/390

3.11.1

-------------------

(This release source code is identical to ``3.11.0`` except a small internal fix to deployment/CI)

* Fixed introspection for failed ``assert_has_calls`` (`365`_).

* Updated type annotations for ``mocker.patch`` and ``mocker.spy`` (`364`_).

.. _365: https://github.com/pytest-dev/pytest-mock/pull/365
.. _364: https://github.com/pytest-dev/pytest-mock/pull/364

3.11.0

-------------------

* Fixed introspection for failed ``assert_has_calls`` (`365`_).

* Updated type annotations for ``mocker.patch`` and ``mocker.spy`` (`364`_).

.. _365: https://github.com/pytest-dev/pytest-mock/pull/365
.. _364: https://github.com/pytest-dev/pytest-mock/pull/364

3.10.0

-------------------

* Added new ``mocker.stop(m)`` method to stop specific ``mocker.patch`` or ``mocker.spy`` calls (`319`_).

.. _319: https://github.com/pytest-dev/pytest-mock/pull/319

3.9.0

------------------

* Expose ``NonCallableMagicMock`` via the ``mocker`` fixture (`318`_).

.. _318: https://github.com/pytest-dev/pytest-mock/pull/318

3.8.2

------------------

- Fixed ``AsyncMock`` support for Python 3.7+ in ``mocker.async_stub`` (`302`_).

.. _302: https://github.com/pytest-dev/pytest-mock/pull/302

3.8.1

------------------

* Fixed regression caused by an explicit ``mock`` dependency in the code (`298`_).

.. _298: https://github.com/pytest-dev/pytest-mock/issues/298

3.8.0

------------------

* Add ``MockerFixture.async_mock`` method. Thanks `PerchunPak`_ for the PR (`296`_).

.. _PerchunPak: https://github.com/PerchunPak
.. _296: https://github.com/pytest-dev/pytest-mock/pull/296

3.7.0

------------------

* Python 3.10 now officially supported.
* Dropped support for Python 3.6.

3.6.1

------------------

* Fix ``mocker.resetall()`` when using ``mocker.spy()`` (`237`_). Thanks `blaxter`_ for the report and `shadycuz`_ for the PR.

.. _blaxter: https://github.com/blaxter
.. _shadycuz: https://github.com/shadycuz
.. _237: https://github.com/pytest-dev/pytest-mock/issues/237

3.6.0

------------------

* pytest-mock no longer supports Python 3.5.

* Correct type annotations for ``mocker.patch.object`` to also include the string form.
Thanks `plannigan`_ for the PR (`235`_).

* ``reset_all`` now supports ``return_value`` and ``side_effect`` keyword arguments. Thanks `alex-marty`_ for the PR (`214`_).

.. _alex-marty: https://github.com/alex-marty
.. _plannigan: https://github.com/plannigan
.. _214: https://github.com/pytest-dev/pytest-mock/pull/214
.. _235: https://github.com/pytest-dev/pytest-mock/pull/235

3.5.1

------------------

* Use ``inspect.getattr_static`` instead of resorting to ``object.__getattribute__``
magic. This should better comply with objects which implement a custom descriptor
protocol. Thanks `yesthesoup`_ for the PR (`224`_).

.. _yesthesoup: https://github.com/yesthesoup
.. _224: https://github.com/pytest-dev/pytest-mock/pull/224

3.5.0

------------------

* Now all patch functions will emit a warning instead of raising a ``ValueError`` when used
as a context-manager. Thanks `iforapsy`_ for the PR (`221`_).

* Additionally, ``mocker.patch.context_manager`` is available when the user intends to mock
a context manager (for example  ``threading.Lock`` object), which will not emit that
warning.

.. _iforapsy: https://github.com/iforapsy
.. _221: https://github.com/pytest-dev/pytest-mock/pull/221

3.4.0

------------------

* Add `mock.seal` alias to the `mocker` fixture (`211`_). Thanks `coiax`_ for the PR.

* Fixed spying on exceptions not covered by the ``Exception``
superclass (`215`_), like ``KeyboardInterrupt`` -- PR `216`_
by `webknjaz`_.

Before the fix, both ``spy_return`` and ``spy_exception``
were always assigned to ``None``
whenever such an exception happened. And after this fix,
``spy_exception`` is set to a correct value of an exception
that has actually happened.

.. _coiax: https://github.com/coiax
.. _webknjaz: https://github.com/sponsors/webknjaz
.. _211: https://github.com/pytest-dev/pytest-mock/pull/211
.. _215: https://github.com/pytest-dev/pytest-mock/issues/215
.. _216: https://github.com/pytest-dev/pytest-mock/pull/216

3.3.1

------------------

* Introduce ``MockFixture`` as an alias to ``MockerFixture``.

Before ``3.3.0``, the fixture class was named ``MockFixture``, but was renamed to ``MockerFixture`` to better
match the ``mocker`` fixture. While not officially part of the API, it was later discovered that this broke
the code of some users which already imported ``pytest_mock.MockFixture`` for type annotations, so we
decided to reintroduce the name as an alias.

Note however that this is just a stop gap measure, and new code should use ``MockerFixture`` for type annotations.

* Improved typing for ``MockerFixture.patch``  (`201`_). Thanks `srittau`_ for the PR.

.. _srittau: https://github.com/srittau
.. _201: https://github.com/pytest-dev/pytest-mock/pull/201

3.3.0

------------------

* ``pytest-mock`` now includes inline type annotations and exposes them to user programs. The ``mocker`` fixture returns ``pytest_mock.MockerFixture``, which can be used to annotate your tests:

.. code-block:: python

     from pytest_mock import MockerFixture

     def test_foo(mocker: MockerFixture) -> None:
         ...

The type annotations were developed against mypy version ``0.782``, the
minimum version supported at the moment. If you run into an error that you believe to be incorrect, please open an issue.

Many thanks to `staticdev`_ for providing the initial patch (`199`_).

.. _staticdev: https://github.com/staticdev
.. _199: https://github.com/pytest-dev/pytest-mock/pull/199

3.2.0

------------------

* `AsyncMock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.AsyncMock>`__ is now exposed in ``mocker`` and supports provides assertion introspection similar to ``Mock`` objects.

Added by `tirkarthi`_ in `197`_.

.. _tirkarthi: https://github.com/tirkarthi
.. _197: https://github.com/pytest-dev/pytest-mock/pull/197

3.1.1

------------------

* Fixed performance regression caused by the ``ValueError`` raised
when ``mocker`` is used as context manager (`191`_).

.. _191: https://github.com/pytest-dev/pytest-mock/issues/191

3.1.0

------------------

* New mocker fixtures added that allow using mocking functionality in other scopes:

* ``class_mocker``
* ``module_mocker``
* ``package_mocker``
* ``session_mocker``

Added by `scorphus`_ in `182`_.

.. _scorphus: https://github.com/scorphus
.. _182: https://github.com/pytest-dev/pytest-mock/pull/182

3.0.0

------------------

* Python 2.7 and 3.4 are no longer supported. Users using ``pip 9`` or later will install
a compatible version automatically.

* ``mocker.spy`` now also works with ``async def`` functions (`179`_). Thanks `frankie567`_ for the PR!

.. _179: https://github.com/pytest-dev/pytest-mock/issues/179
.. _frankie567: https://github.com/frankie567

2.0.0

------------------

Breaking Changes
++++++++++++++++

* ``mocker.spy`` attributes for tracking returned values and raised exceptions of its spied functions
are now called ``spy_return`` and ``spy_exception``, instead of reusing the existing
``MagicMock`` attributes ``return_value`` and ``side_effect``.

Version ``1.13`` introduced a serious regression: after a spied function using ``mocker.spy``
raises an exception, further calls to the spy will not call the spied function,
always raising the first exception instead: assigning to ``side_effect`` causes
``unittest.mock`` to behave this way (`175`_).

* The deprecated ``mock`` alias to the ``mocker`` fixture has finally been removed.

.. _175: https://github.com/pytest-dev/pytest-mock/issues/175

1.13.0

-------------------

* The object returned by ``mocker.spy`` now also tracks any side effect
of the spied method/function.

1.12.1

-------------------

* Fix error if ``mocker.patch`` is used in code where the source file
is not available, for example stale ``.pyc`` files (`169`_).

.. _169: https://github.com/pytest-dev/pytest-mock/issues/169#issuecomment-555729265

1.12.0

-------------------

* Now all patch functions also raise a ``ValueError`` when used
as a context-manager. Thanks `AlexGascon`_ for the PR (`168`_).

.. _AlexGascon: https://github.com/AlexGascon
.. _168: https://github.com/pytest-dev/pytest-mock/pull/168

1.11.2

-------------------

* The *pytest introspection follows* message is no longer shown
if there is no pytest introspection (`154`_).
Thanks `The-Compiler`_ for the report.

* ``mocker`` now raises a ``ValueError`` when used as a context-manager.
Thanks `binarymason`_ for the PR (`165`_).

.. _154: https://github.com/pytest-dev/pytest-mock/issues/154
.. _165: https://github.com/pytest-dev/pytest-mock/pull/165
.. _binarymason: https://github.com/binarymason

1.11.1

-------------------

* Fix ``mocker.spy`` on Python 2 when used on non-function objects
which implement ``__call__`` (`157`_). Thanks `pbasista`_  for
the report.

.. _157: https://github.com/pytest-dev/pytest-mock/issues/157
.. _pbasista: https://github.com/pbasista

1.11.0

------

* The object returned by ``mocker.spy`` now also tracks the return value
of the spied method/function.

1.10.4

------

* Fix plugin when 'terminal' plugin is disabled

1.10.3

------

* Fix test suite in Python 3.8. Thanks `hroncok`_ for the report and `blueyed`_ for the PR (`140`_).

.. _140: https://github.com/pytest-dev/pytest-mock/pull/140
.. _hroncok: https://github.com/hroncok

1.10.2

------

* Fix bug at the end of the test session when a call to ``patch.stopall`` is done explicitly by
user code. Thanks `craiga`_ for the report (`137`_).

.. _137: https://github.com/pytest-dev/pytest-mock/issues/137
.. _craiga: https://github.com/craiga

1.10.1

------

* Fix broken links and update README. Also the code is now formatted using `black <https://github.com/ambv/black>`__.

1.10.0

------

* Add support for the recently added ``assert_called`` method in Python 3.6 and ``mock-2.0``. Thanks `rouge8`_ for the PR (`115`_).

.. _115: https://github.com/pytest-dev/pytest-mock/pull/115

1.9.0

-----

* Add support for the recently added ``assert_called_once`` method in Python 3.6 and ``mock-2.0``. Thanks `rouge8`_ for the PR (`113`_).

.. _113: https://github.com/pytest-dev/pytest-mock/pull/113

1.8.0

-----

* Add aliases for ``NonCallableMock`` and ``create_autospec`` to ``mocker``. Thanks `mlhamel`_ for the PR (`111`_).

.. _111: https://github.com/pytest-dev/pytest-mock/pull/111

1.7.1

-----

* Fix ``setup.py`` to correctly read the ``README.rst``. Thanks `ghisvail`_ for the fix (`107`_).

.. _107: https://github.com/pytest-dev/pytest-mock/issues/107

1.7.0

-----

**Incompatible change**

* ``pytest-mock`` no longer supports Python 2.6 and Python 3.3, following the lead of
``pytest`` and other projects in the community. Thanks `hugovk`_ for the PR (`96`_).

**Packaging**

* Fix ``mock`` requirement in Python 2. Thanks `ghisvail`_ for the report (`101`_).

**Internal**

* Some tests in ``pytest-mock``'s suite are skipped if assertion rewriting is disabled (`102`_).

.. _ghisvail: https://github.com/ghisvail
.. _hugovk: https://github.com/hugovk
.. _96: https://github.com/pytest-dev/pytest-mock/pull/96
.. _101: https://github.com/pytest-dev/pytest-mock/issues/101
.. _102: https://github.com/pytest-dev/pytest-mock/issues/102
Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant