testing-cabal / mock

The Python mock library

Home Page:https://docs.python.org/dev/library/unittest.mock.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

_patch._active_patches is global to all patches

Larrik opened this issue · comments

I found this out the hard way, but when you create and start, say 5 different patches over 5 different methods, all 5 Mock objects live in a single _active_patches list shared by all _patch objects. This is weird behavior.

Side note, is there a better way to determine if a patch is running before trying to stop it?

I'm thinking this was probably intentional, but it seems odd.

This repo is only for issues that are specific to the backport.
Please report issues with mock in the upstream bug tracker at https://bugs.python.org/.
Once issues are fixed upstream, they can be backported here.