[issue21600] mock.patch.stopall doesn't work with patch.dict to sys.modules

fumihiko kakuma report at bugs.python.org
Mon Jun 2 12:49:55 CEST 2014


fumihiko kakuma added the comment:

Checking mock.py(version 1.0.1) it seems that patch.stopall does not support patch.dict. Does it have any problem to support ptch.dict by stopall.
I made the attached patch file for this. It seems to work well. How about this?

But I don't know why sys.modules refers the first mock object. 

$ python test_samp.py
test_samp1 (__main__.SampTestCase) ... foo_mod=<Mock id='140164117280080'>
myfunc foo=<Mock id='140164117280080'>
>>> stopall patch
ok
test_samp2 (__main__.SampTestCase) ... foo_mod=<Mock id='140164117280208'>
myfunc foo=<Mock id='140164117280208'>
>>> stopall patch
ok
test_samp3 (__main__.SampTestCase) ... foo_mod=<Mock id='140164117280464'>
myfunc foo=<Mock id='140164117280464'>
>>> stopall patch
ok

----------------------------------------------------------------------
Ran 3 tests in 0.001s

OK
$

----------
keywords: +patch
Added file: http://bugs.python.org/file35445/add_stopall_patch_dict.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21600>
_______________________________________


More information about the Python-bugs-list mailing list