This repository has been archived by the owner on Nov 2, 2021. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
==1.13.0
->==3.6.1
Release Notes
pytest-dev/pytest-mock
v3.6.1
Compare Source
mocker.resetall()
when usingmocker.spy()
(#237
). Thanks@blaxter
for the report and@shadycuz
_ for the PR... _@blaxter: https://github.com/blaxter
.. _@shadycuz: https://github.com/shadyc[https://github.com/pytest-dev/pytest-mock/issues/237](https://togithub.com/pytest-dev/pytest-mock/issues/237)ytest-mock/issues/237
v3.6.0
Compare Source
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 supportsreturn_value
andside_effect
keyword arguments. Thanks@alex-marty
_ for the PR (#214
_)... _@alex-marty: https://github.com/alex-marty
.. _@plannigan: https://github.com/plannig[https://github.com/pytest-dev/pytest-mock/pull/214](https://togithub.com/pytest-dev/pytest-mock/pull/214)/pytest-mock[https://github.com/pytest-dev/pytest-mock/pull/235](https://togithub.com/pytest-dev/pytest-mock/pull/235)est-dev/pytest-mock/pull/235
v3.5.1
Compare Source
inspect.getattr_static
instead of resorting toobject.__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
.. [https://github.com/pytest-dev/pytest-mock/pull/224](https://togithub.com/pytest-dev/pytest-mock/pull/224)-mock/pull/224
v3.5.0
Compare Source
Now all patch functions will emit a warning instead of raising a
ValueError
when usedas a context-manager. Thanks
@iforapsy
_ for the PR (#221
_).Additionally,
mocker.patch.context_manager
is available when the user intends to mocka context manager (for example
threading.Lock
object), which will not emit thatwarning.
.. _@iforapsy: https://github.com/iforapsy
.. [https://github.com/pytest-dev/pytest-mock/pull/221](https://togithub.com/pytest-dev/pytest-mock/pull/221)-mock/pull/221
v3.4.0
Compare Source
Add
mock.seal
alias to themocker
fixture (#211
). Thanks@coiax
for the PR.Fixed spying on exceptions not covered by the
Exception
superclass (
#215
), likeKeyboardInterrupt
-- PR#216
by
@webknjaz
_.Before the fix, both
spy_return
andspy_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 exceptionthat has actually happened.
.. _@coiax: https://github.com/coiax
.. _@webknjaz: https://github.com/sponsors/webknj[https://github.com/pytest-dev/pytest-mock/pull/211](https://togithub.com/pytest-dev/pytest-mock/pull/211)/pytest-mock[https://github.com/pytest-dev/pytest-mock/issues/215](https://togithub.com/pytest-dev/pytest-mock/issues/215)t-dev/pytest[https://github.com/pytest-dev/pytest-mock/pull/216](https://togithub.com/pytest-dev/pytest-mock/pull/216)com/pytest-dev/pytest-mock/pull/216
v3.3.1
Compare Source
Introduce
MockFixture
as an alias toMockerFixture
.Before
3.3.0
, the fixture class was namedMockFixture
, but was renamed toMockerFixture
to bettermatch the
mocker
fixture. While not officially part of the API, it was later discovered that this brokethe code of some users which already imported
pytest_mock.MockFixture
for type annotations, so wedecided 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
.. [https://github.com/pytest-dev/pytest-mock/pull/201](https://togithub.com/pytest-dev/pytest-mock/pull/201)-mock/pull/201
v3.3.0
Compare Source
pytest-mock
now includes inline type annotations and exposes them to user programs. Themocker
fixture returnspytest_mock.MockerFixture
, which can be used to annotate your tests:.. code-block:: python
The type annotations were developed against mypy version
0.782
, theminimum 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
.. [https://github.com/pytest-dev/pytest-mock/pull/199](https://togithub.com/pytest-dev/pytest-mock/pull/199)-mock/pull/199
v3.2.0
Compare Source
AsyncMock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.AsyncMock>
__ is now exposed inmocker
and supports provides assertion introspection similar toMock
objects.Added by
@tirkarthi
_ in#197
_... _@tirkarthi: https://github.com/tirkarthi
.. [https://github.com/pytest-dev/pytest-mock/pull/197](https://togithub.com/pytest-dev/pytest-mock/pull/197)-mock/pull/197
v3.1.1
Compare Source
ValueError
raisedwhen
mocker
is used as context manager (#191
_)... _#̴https://github.com/pytest-dev/pytest-mock/issues/191ues/191
v3.1.0
Compare Source
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
.. [https://github.com/pytest-dev/pytest-mock/pull/182](https://togithub.com/pytest-dev/pytest-mock/pull/182)-mock/pull/182
v3.0.0
Compare Source
Python 2.7 and 3.4 are no longer supported. Users using
pip 9
or later will installa compatible version automatically.
mocker.spy
now also works withasync def
functions (#179
). Thanks@frankie567
for the PR!.. _#̴https://github.com/pytest-dev/pytest-mock/issues/179ues/179
.. _@frankie567: https://github.com/frankie567
v2.0.0
Compare Source
Breaking Changes
++++++++++++++++
mocker.spy
attributes for tracking returned values and raised exceptions of its spied functionsare now called
spy_return
andspy_exception
, instead of reusing the existingMagicMock
attributesreturn_value
andside_effect
.Version
1.13
introduced a serious regression: after a spied function usingmocker.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
causesunittest.mock
to behave this way (#175
_).The deprecated
mock
alias to themocker
fixture has finally been removed... _#̴https://github.com/pytest-dev/pytest-mock/issues/175ues/175
Configuration
📅 Schedule: At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Renovate will not automatically rebase this PR, because other commits have been found.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by WhiteSource Renovate. View repository job log here.