Skip to content
Snippets Groups Projects
Commit dbd92b90 authored by Michael Foord's avatar Michael Foord
Browse files

Blank line additions

parent 8b3e9b7c
No related branches found
No related tags found
No related merge requests found
......@@ -181,10 +181,12 @@ sentinel = Sentinel()
DEFAULT = sentinel.DEFAULT
class OldStyleClass:
pass
ClassType = type(OldStyleClass)
def _copy(value):
if type(value) in (dict, list, tuple, set):
return type(value)(value)
......@@ -251,6 +253,7 @@ class Mock(object):
new = type(cls.__name__, (cls,), {'__doc__': cls.__doc__})
return object.__new__(new)
def __init__(self, spec=None, side_effect=None, return_value=DEFAULT,
wraps=None, name=None, spec_set=False, parent=None):
self._parent = parent
......@@ -277,12 +280,14 @@ class Mock(object):
self.reset_mock()
@property
def __class__(self):
if self._spec_class is None:
return type(self)
return self._spec_class
def reset_mock(self):
"Restore the mock object to its initial state."
self.called = False
......@@ -359,6 +364,7 @@ class Mock(object):
return self._children[name]
def __repr__(self):
if self._name is None and self._spec_class is None:
return object.__repr__(self)
......@@ -386,6 +392,7 @@ class Mock(object):
spec_string,
id(self))
def __setattr__(self, name, value):
if not 'method_calls' in self.__dict__:
# allow all attribute setting until initialisation is complete
......@@ -482,6 +489,7 @@ class callargs(tuple):
return tuple(args_kwargs) == (other_args, other_kwargs)
def _dot_lookup(thing, comp, import_path):
try:
return getattr(thing, comp)
......@@ -525,6 +533,7 @@ class _patch(object):
else:
return self.decorate_callable(func)
def decorate_class(self, klass):
for attr in dir(klass):
attr_value = getattr(klass, attr)
......@@ -532,6 +541,7 @@ class _patch(object):
setattr(klass, attr, self.copy()(attr_value))
return klass
def decorate_callable(self, func):
if hasattr(func, 'patchings'):
func.patchings.append(self)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment