Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:

Copying my comment from GitHub : 

This issue occurs only when the mock module import and code are executed under 
tracing. In order to test this I have tried patching sys.modules to remove 
unittest.mock in order to trigger an import under tracing. Though unittest.mock 
is deleted reference to unittest.mock.patch is held by two tests 
(test_patch_dict_test_prefix and test_patch_test_prefix) that change the 
TEST_PREFIX. Hence somehow there is a difference in the unittest.mock.patch 
object referred under these tests and inside mock module causing reference to 
unchanged TEST_PREFIX and hence test case failures. So I have kept a reference 
to old patch object and restored it in the end of this test to make sure 
everything is in sync.

There is some difficulty in testing this since the import needs to be executed 
under tracing and manipulating sys.modules to delete unittest.mock and reimport 
causes some old references in other tests to go out of sync. A clean way to do 
this would be to have this test as a separate file and hence not impacting 
other tests but I am not sure if it's worth enough to justify a separate file 
to test this. Maybe I am missing something here on a better way to test this. 
Any guidance would be helpful.

Thanks

----------
keywords:  -patch
nosy: +cjw296, mariocj89
stage: patch review -> 
versions: +Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36593>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to