diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d18f6d6..6836013 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,7 @@ Unreleased * `#547 `_: Added ``SpyType`` for annotating ``mocker.spy`` results. * Dropped support for EOL Python 3.9. +* `#147 `_: Removed handling of ``RuntimeError: stop called on unstarted patcher``, which can no longer occur in the supported Python versions. 3.15.1 ------ diff --git a/src/pytest_mock/plugin.py b/src/pytest_mock/plugin.py index eaf1488..df63fb4 100644 --- a/src/pytest_mock/plugin.py +++ b/src/pytest_mock/plugin.py @@ -696,17 +696,7 @@ def wrap_assert_methods(config: Any) -> None: def unwrap_assert_methods() -> None: for patcher in _mock_module_patches: - try: - patcher.stop() - except RuntimeError as e: - # a patcher might have been stopped by user code (#137) - # so we need to catch this error here and ignore it; - # unfortunately there's no public API to check if a patch - # has been started, so catching the error it is - if str(e) == "stop called on unstarted patcher": - pass - else: - raise + patcher.stop() _mock_module_patches[:] = [] _mock_module_originals.clear()