Skip to content

Remove RuntimeError handling obsolete since mock 3.0.0 (#147) - #599

Merged
nicoddemus merged 1 commit into
pytest-dev:mainfrom
Rishithar2207:remove-runtime-error-handling-147
Aug 13, 2026
Merged

Remove RuntimeError handling obsolete since mock 3.0.0 (#147)#599
nicoddemus merged 1 commit into
pytest-dev:mainfrom
Rishithar2207:remove-runtime-error-handling-147

Conversation

@Rishithar2207

Copy link
Copy Markdown
Contributor

Closes #147.

The RuntimeError: stop called on unstarted patcher handling in unwrap_assert_methods was added for #137, when calling stop() on an already-stopped patcher raised. That raise was removed from CPython in mock 3.0.0 (bpo-36366), so the branch is unreachable on any currently supported version.

Verification:

  • pytest-mock requires Python >=3.10; the raise was removed in mock 3.0.0 / CPython 3.8.
  • The string "stop called on unstarted patcher" does not appear anywhere in unittest/mock.py on 3.12.
  • Calling patcher.stop() twice on 3.12 is a silent no-op rather than raising.

No behaviour change for users. Local test results are unchanged from main (the four failing introspection tests fail identically before and after this change, unrelated to it).

@nicoddemus
nicoddemus merged commit ccd1a15 into pytest-dev:main Aug 13, 2026
16 checks passed
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.

Drop RuntimeError handling when we only support Python 3.8+

2 participants