Fixed compatiblity issues in stubout

This commit is contained in:
Przemyslaw Gajda 2012-04-23 00:13:21 +02:00
parent b13fe45f54
commit 7de1beb8c8
1 changed files with 2 additions and 2 deletions

View File

@ -61,7 +61,7 @@ class StubOutForTesting:
Raises AttributeError if the attribute cannot be found.
"""
if (inspect.ismodule(obj) or
(not inspect.isclass(obj) and obj.__dict__.has_key(attr_name))):
(not inspect.isclass(obj) and attr_name in obj.__dict__)):
orig_obj = obj
orig_attr = getattr(obj, attr_name)
@ -124,7 +124,7 @@ class StubOutForTesting:
if isinstance(old_attribute, staticmethod):
old_child = staticmethod(old_child)
elif isinstance(old_attribute, classmethod):
old_child = classmethod(old_child.im_func)
old_child = classmethod(old_child.__func__)
self.cache.append((parent, old_child, child_name))
setattr(parent, child_name, new_child)