summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2012-05-27 08:17:07 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2012-05-27 08:17:07 (GMT)
commit0b43bcf5287d9494e3332b391350fcd32fe93f2c (patch)
tree4afedcf7ea32b14bb3c9a46fb8fd9532e9344bd0 /Lib/unittest/mock.py
parent5c6eba3a93ce5fe989e372a8b12f535c72fc4e8f (diff)
downloadcpython-0b43bcf5287d9494e3332b391350fcd32fe93f2c.zip
cpython-0b43bcf5287d9494e3332b391350fcd32fe93f2c.tar.gz
cpython-0b43bcf5287d9494e3332b391350fcd32fe93f2c.tar.bz2
Close #14857: fix regression in references to PEP 3135 implicit __class__ closure variable. Reopens issue #12370, but also updates unittest.mock to workaround that issue
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r--Lib/unittest/mock.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index a94acd6..36be0fd 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -39,6 +39,9 @@ if 'java' in sys.platform:
FILTER_DIR = True
+# Workaround for issue #12370
+# Without this, the __class__ properties wouldn't be set correctly
+_safe_super = super
def _is_instance_mock(obj):
# can't use isinstance on Mock objects because they override __class__
@@ -397,7 +400,7 @@ class NonCallableMock(Base):
if kwargs:
self.configure_mock(**kwargs)
- super(NonCallableMock, self).__init__(
+ _safe_super(NonCallableMock, self).__init__(
spec, wraps, name, spec_set, parent,
_spec_state
)
@@ -820,7 +823,7 @@ class CallableMixin(Base):
_spec_state=None, _new_name='', _new_parent=None, **kwargs):
self.__dict__['_mock_return_value'] = return_value
- super(CallableMixin, self).__init__(
+ _safe_super(CallableMixin, self).__init__(
spec, wraps, name, spec_set, parent,
_spec_state, _new_name, _new_parent, **kwargs
)
@@ -1690,7 +1693,7 @@ def _set_return_value(mock, method, name):
class MagicMixin(object):
def __init__(self, *args, **kw):
- super(MagicMixin, self).__init__(*args, **kw)
+ _safe_super(MagicMixin, self).__init__(*args, **kw)
self._mock_set_magics()