summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorMichael Foord <michael@voidspace.org.uk>2012-03-14 21:40:22 (GMT)
committerMichael Foord <michael@voidspace.org.uk>2012-03-14 21:40:22 (GMT)
commita74b3aa0cce004bfa8a8be04519667a70d5651b0 (patch)
treea4dfed6da54b06136388a4047f63cdfbc39884c4 /Lib/unittest/mock.py
parente7c8fdee18494238cc93eb895001398ceb7d12fb (diff)
downloadcpython-a74b3aa0cce004bfa8a8be04519667a70d5651b0.zip
cpython-a74b3aa0cce004bfa8a8be04519667a70d5651b0.tar.gz
cpython-a74b3aa0cce004bfa8a8be04519667a70d5651b0.tar.bz2
Remove more Python 2 compatibility cruft from unittest.mock
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r--Lib/unittest/mock.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 89fe232..f014c51 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -143,13 +143,10 @@ def _instance_callable(obj):
# already an instance
return getattr(obj, '__call__', None) is not None
- klass = obj
- # uses __bases__ instead of __mro__ so that we work with old style classes
- if klass.__dict__.get('__call__') is not None:
- return True
-
- for base in klass.__bases__:
- if _instance_callable(base):
+ # *could* be broken by a class overriding __mro__ or __dict__ via
+ # a metaclass
+ for base in (obj,) + obj.__mro__:
+ if base.__dict__.get('__call__') is not None:
return True
return False
@@ -2064,11 +2061,7 @@ def _must_skip(spec, entry, is_type):
if entry in getattr(spec, '__dict__', {}):
# instance attribute - shouldn't skip
return False
- # can't use type because of old style classes
spec = spec.__class__
- if not hasattr(spec, '__mro__'):
- # old style class: can't have descriptors anyway
- return is_type
for klass in spec.__mro__:
result = klass.__dict__.get(entry, DEFAULT)