unittest.mock from stdlib should come last

--HG--
branch : mock-unittest-252
This commit is contained in:
Nicolas Delaby 2014-07-27 12:11:39 +02:00
parent e6ad6e02d2
commit 2e55c4ba61
1 changed files with 4 additions and 2 deletions

View File

@ -1866,8 +1866,10 @@ def handle_mock_module_patching(function, startindex):
Special treatment when test_function is decorated
by mock.patch
"""
for candidate_module_name in ('unittest.mock', 'mock'):
# stdlib comes first
for candidate_module_name in ('mock', 'unittest.mock'):
# stdlib comes last, because mock might be also installed
# as a third party with upgraded version compare to
# unittest.mock
try:
mock = sys.modules[candidate_module_name]
except KeyError: