summaryrefslogtreecommitdiff
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2014-04-14 13:32:35 -0700
committerGregory P. Smith <greg@krypto.org>2014-04-14 13:32:35 -0700
commitf54fbada41e23ee9bc19b88682fda7dac6bb7f20 (patch)
treee024ba06589acc49850eaba0b47d8f11ec7b1971 /Lib/unittest/mock.py
parentb396a2ab49153999400eee998bf1c9564d5c3021 (diff)
parentfddcfa27fab71ceb6a9df3f4edf46e94ee1da94f (diff)
downloadcpython-git-f54fbada41e23ee9bc19b88682fda7dac6bb7f20.tar.gz
merge heads
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r--Lib/unittest/mock.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index f1f65221d4..2dd4ca5271 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -27,9 +27,13 @@ __version__ = '1.0'
import inspect
import pprint
import sys
+import builtins
+from types import ModuleType
from functools import wraps, partial
+_builtins = {name for name in dir(builtins) if not name.startswith('_')}
+
BaseExceptions = (BaseException,)
if 'java' in sys.platform:
# jython
@@ -1166,6 +1170,9 @@ class _patch(object):
else:
local = True
+ if name in _builtins and isinstance(target, ModuleType):
+ self.create = True
+
if not self.create and original is DEFAULT:
raise AttributeError(
"%s does not have the attribute %r" % (target, name)