diff options
author | Gregory P. Smith <greg@krypto.org> | 2014-04-14 13:32:35 -0700 |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2014-04-14 13:32:35 -0700 |
commit | f54fbada41e23ee9bc19b88682fda7dac6bb7f20 (patch) | |
tree | e024ba06589acc49850eaba0b47d8f11ec7b1971 /Lib/unittest/mock.py | |
parent | b396a2ab49153999400eee998bf1c9564d5c3021 (diff) | |
parent | fddcfa27fab71ceb6a9df3f4edf46e94ee1da94f (diff) | |
download | cpython-git-f54fbada41e23ee9bc19b88682fda7dac6bb7f20.tar.gz |
merge heads
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r-- | Lib/unittest/mock.py | 7 |
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) |