Skip to content

Releases: pytest-dev/pytest-mock

3.6.1 (2021-05-06)

18 May 11:53
Compare
Choose a tag to compare
  • Fix mocker.resetall() when using mocker.spy() (#237). Thanks @blaxter for the report and @shadycuz for the PR.

3.6.0 (2021-04-24)

18 May 11:53
Compare
Choose a tag to compare
  • 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).

3.5.1 (2021-01-10)

18 May 11:52
Compare
Choose a tag to compare
  • 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).

3.5.0 (2021-01-04)

18 May 11:52
Compare
Choose a tag to compare
  • 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.

3.4.0 (2020-12-15)

18 May 11:51
Compare
Choose a tag to compare
  • Add [mock.seal]{.title-ref} alias to the [mocker]{.title-ref} 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

3.3.1 (2020-08-24)

26 Aug 11:05
Compare
Choose a tag to compare
  • 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.

3.3.0 (2020-08-21)

22 Aug 00:33
Compare
Choose a tag to compare
  • 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:

    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.

3.2.0 (2020-07-11)

11 Jul 16:09
Compare
Choose a tag to compare
  • AsyncMock is now exposed in mocker and supports provides assertion introspection similar to Mock objects.

    Added by @tirkarthi in #197.

3.1.1 (2020-05-31)

05 Jun 11:41
Compare
Choose a tag to compare
  • Fixed performance regression caused by the ValueError raised
    when mocker is used as context manager (#191).

3.1.0 (2020-04-18)

15 May 14:30
Compare
Choose a tag to compare
  • 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.