Pytest-mock

Latest version: v3.14.0

Safety actively analyzes 628918 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 8 of 11

1.5.0

-----

* New ``mocker.mock_module`` variable points to the underlying mock module being used
(``unittest.mock`` or ``mock``).
Thanks `blueyed`_ for the request (`71`_).

.. _71: https://github.com/pytest-dev/pytest-mock/pull/71

1.4.0

-----

* New configuration variable, ``mock_use_standalone_module`` (defaults to ``False``). This forces
the plugin to import ``mock`` instead of ``unittest.mock`` on Python 3. This is useful to import
a newer version than the one available in the Python distribution.

* Previously the plugin would first try to import ``mock`` and fallback to ``unittest.mock``
in case of an ``ImportError``, but this behavior has been removed because it could hide
hard to debug import errors (`68`_).

* Now ``mock`` (Python 2) and ``unittest.mock`` (Python 3) are lazy-loaded to make it possible to
implement the new ``mock_use_standlone_module`` configuration option. As a consequence of this
the undocumented ``pytest_mock.mock_module`` variable, which pointed to the actual mock module
being used by the plugin, has been removed.

* `DEFAULT <https://docs.python.org/3/library/unittest.mock.html#default>`_ is now available from
the ``mocker`` fixture.

.. _68: https://github.com/pytest-dev/pytest-mock/issues/68

1.3.0

-----

* Add support for Python 3.6. Thanks `hackebrot`_ for the report (`59`_).

* ``mock.mock_open`` is now aliased as ``mocker.mock_open`` for convenience.
Thanks `pokidovea`_ for the PR (`66`_).

.. _hackebrot: https://github.com/hackebrot
.. _pokidovea: https://github.com/pokidovea
.. _59: https://github.com/pytest-dev/pytest-mock/issues/59
.. _66: https://github.com/pytest-dev/pytest-mock/pull/66

1.2

---

* Try to import ``mock`` first instead of ``unittest.mock``. This gives the user flexibility
to install a newer ``mock`` version from PyPI instead of using the one available in the
Python distribution.
Thanks `wcooley`_ for the PR (`54`_).

* ``mock.sentinel`` is now aliased as ``mocker.sentinel`` for convenience.
Thanks `kjwilcox`_ for the PR (`56`_).

.. _wcooley: https://github.com/wcooley
.. _kjwilcox: https://github.com/kjwilcox
.. _54: https://github.com/pytest-dev/pytest-mock/issues/54
.. _56: https://github.com/pytest-dev/pytest-mock/pull/56

1.1

---

* From this version onward, ``pytest-mock`` is licensed under the `MIT`_ license (`45`_).

* Now the plugin also adds introspection information on differing call arguments when
calling helper methods such as ``assert_called_once_with``. The extra introspection
information is similar to pytest's and can be disabled with the ``mock_traceback_monkeypatch``
option.
Thanks `asfaltboy`_ for the PR (`36`_).

* ``mocker.stub()`` now allows passing in the name for the constructed ``Mock``
object instead of having to set it using the internal ``_mock_name`` attribute
directly. This is useful for debugging as the name is used in the mock's
``repr`` string as well as related assertion failure messages.
Thanks `jurko-gospodnetic`_ for the PR (`40`_).

* Monkey patching ``mock`` module for friendlier tracebacks is automatically disabled
with the ``--tb=native`` option. The underlying
mechanism used to suppress traceback entries from ``mock`` module does not work with that option
anyway plus it generates confusing messages on Python 3.5 due to exception chaining (`44`_).
Thanks `blueyed`_ for the report.

* ``mock.call`` is now aliased as ``mocker.call`` for convenience.
Thanks `jhermann`_ for the PR (`49`_).

.. _jurko-gospodnetic: https://github.com/jurko-gospodnetic
.. _asfaltboy: https://github.com/asfaltboy
.. _jhermann: https://github.com/jhermann
.. _45: https://github.com/pytest-dev/pytest-mock/issues/45
.. _36: https://github.com/pytest-dev/pytest-mock/issues/36
.. _40: https://github.com/pytest-dev/pytest-mock/issues/40
.. _44: https://github.com/pytest-dev/pytest-mock/issues/44
.. _49: https://github.com/pytest-dev/pytest-mock/issues/49
.. _MIT: https://github.com/pytest-dev/pytest-mock/blob/master/LICENSE

1.0

---

* Fix AttributeError with ``mocker.spy`` when spying on inherited methods
(`42`_). Thanks `blueyed`_ for the PR.

.. _blueyed: https://github.com/blueyed
.. _42: https://github.com/pytest-dev/pytest-mock/issues/42

Page 8 of 11

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.