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

2020-01-24 Thread Chris Withers
Change by Chris Withers : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

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

2019-12-14 Thread Mario Corchero
Change by Mario Corchero : -- pull_requests: +17075 stage: test needed -> patch review pull_request: https://github.com/python/cpython/pull/17606 ___ Python tracker ___

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

2019-12-13 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks Mario. I think the last patch attached to the issue is complete with tests and needs to be updated master. Feel free to raise a PR. -- ___ Python tracker

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

2019-12-13 Thread Mario Corchero
Mario Corchero added the comment: Makes total sense, I think we should get this for 3.9. Not sure I'll backport this, even if a bugfix it might cause unexpected changes (Though I'd be OK with it, given that calling stop twice causes no issue). I'm happy to push a PR with the proposed change

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

2019-12-13 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: This sounds like a good idea given the docs and the general agreement in the thread. I would like to target this for 3.9 . Differentiation between the normal patches and the ones from patch.dict is nice but given that docstring indicates LIFO for

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

2018-07-20 Thread ppperry
Change by ppperry : -- title: mock.patch.stopall doesn't work with patch.dict to sys.modules -> mock.patch.stopall doesn't work with patch.dict ___ Python tracker ___

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

2018-07-20 Thread Antoni Szych
Antoni Szych added the comment: Hi, Any chance of getting this resolved 1 year later? :) BR -- ___ Python tracker ___ ___

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

2017-07-12 Thread Antoni Szych
Antoni Szych added the comment: Hi, It's been 3 years now since this issue was first raised. We bumped upon this issue while using code like following: def tearDown(): patch.stopall() def test123(): p=patch.dict(...) p.start() assert False p.stop() While

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

2014-12-11 Thread Michael Foord
Michael Foord added the comment: Using patch.dict manipulates the contents of sys.modules, it doesn't replace sys.modules. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21600 ___

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

2014-12-11 Thread Eric Snow
Eric Snow added the comment: Ah. Never mind then. :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21600 ___ ___ Python-bugs-list mailing list

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

2014-12-10 Thread Michael Foord
Michael Foord added the comment: why not? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21600 ___ ___ Python-bugs-list mailing list

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

2014-12-10 Thread Colton Leekley-Winslow
Colton Leekley-Winslow added the comment: Patching sys.modules is an idea I got from the official documentation https://docs.python.org/3/library/unittest.mock.html#patch-dict http://mock.readthedocs.org/en/latest/patch.html#patch-dict -- ___

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

2014-12-10 Thread Eric Snow
Eric Snow added the comment: At least for CPython sys.modules is initially set to the modules dict on the interpreter struct. As of 3.4 the import system itself only cares about sys.modules (I'll have to double check on builtin___import__). However, if I recall correctly at least part of

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

2014-12-09 Thread Eric Snow
Eric Snow added the comment: FYI, you probably don't want to be patching out sys.modules. It isn't guaranteed that doing so will have the expected effect on import semantics. -- nosy: +eric.snow ___ Python tracker rep...@bugs.python.org

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

2014-10-14 Thread Colton Leekley-Winslow
Colton Leekley-Winslow added the comment: What's the status on this? -- nosy: +lwcolton ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21600 ___

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

2014-10-14 Thread Michael Foord
Michael Foord added the comment: It just needs committing, I believe Kushal Das has volunteered to do it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21600 ___

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

2014-10-14 Thread Kushal Das
Kushal Das added the comment: I will do that. New job is taking time. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21600 ___ ___

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

2014-06-08 Thread Michael Foord
Michael Foord added the comment: That looks great - thanks! I'll get it committed shortly. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21600 ___

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

2014-06-08 Thread fumihiko kakuma
fumihiko kakuma added the comment: Thank you in advance. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21600 ___ ___ Python-bugs-list mailing

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

2014-06-07 Thread fumihiko kakuma
fumihiko kakuma added the comment: Hi michael, Certainly, thank you for your many advices. I attached the new patch file. -- Added file: http://bugs.python.org/file35513/support_patch_dict_by_stopall.diff ___ Python tracker rep...@bugs.python.org

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

2014-06-06 Thread fumihiko kakuma
fumihiko kakuma added the comment: Thank you for your reply. Yes, you are right. The patch was too slapdash. I re-created it and added unit tests. -- Added file: http://bugs.python.org/file35499/support_patch_dict_by_stopall.diff ___ Python tracker

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

2014-06-06 Thread Michael Foord
Michael Foord added the comment: That's better - thanks. Another minor tweak needed though. stopall should only stop patches that were started with start, not those used as context managers or decorators (or they will be stopped twice!). See how the main patch object only adds to the set of

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

2014-06-03 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +kushal.das ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21600 ___ ___

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

2014-06-03 Thread Michael Foord
Michael Foord added the comment: Yep, patch.dict wasn't designed with stopall in mind so it needs adding. Thanks for pointing this out and your fix. Your patch isn't quite right, those operations shouldn't be inside the try excepts. (And there are no tests.) -- assignee: -

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

2014-06-02 Thread fumihiko kakuma
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

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

2014-05-29 Thread Ned Deily
Changes by Ned Deily n...@acm.org: -- nosy: +michael.foord ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21600 ___ ___ Python-bugs-list mailing

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

2014-05-28 Thread fumihiko kakuma
New submission from fumihiko kakuma: It seems that stopall doesn't work when do start patch.dict to sys.modules. I show sample scripts the following. Using stopall test case seems to always refer the first mock foo object. But using stop it refers a new mock foo object. $ cat test_sampmod.py