bpo-35357: Add _mock_ prefix to name/parent/from_kall attributes of _Call/_MagicProxy. (#10873)

Fix minor typo in test function name.
This commit is contained in:
Andrew Dunai 2018-12-04 11:08:45 +02:00 committed by Chris Withers
parent eeb719eac6
commit e63e617ebb
4 changed files with 34 additions and 16 deletions

View file

@ -2040,9 +2040,9 @@ class _Call(tuple):
def __init__(self, value=(), name=None, parent=None, two=False,
from_kall=True):
self.name = name
self.parent = parent
self.from_kall = from_kall
self._mock_name = name
self._mock_parent = parent
self._mock_from_kall = from_kall
def __eq__(self, other):
@ -2059,8 +2059,8 @@ class _Call(tuple):
else:
self_name, self_args, self_kwargs = self
if (getattr(self, 'parent', None) and getattr(other, 'parent', None)
and self.parent != other.parent):
if (getattr(self, '_mock_parent', None) and getattr(other, '_mock_parent', None)
and self._mock_parent != other._mock_parent):
return False
other_name = ''
@ -2104,17 +2104,17 @@ class _Call(tuple):
def __call__(self, *args, **kwargs):
if self.name is None:
if self._mock_name is None:
return _Call(('', args, kwargs), name='()')
name = self.name + '()'
return _Call((self.name, args, kwargs), name=name, parent=self)
name = self._mock_name + '()'
return _Call((self._mock_name, args, kwargs), name=name, parent=self)
def __getattr__(self, attr):
if self.name is None:
if self._mock_name is None:
return _Call(name=attr, from_kall=False)
name = '%s.%s' % (self.name, attr)
name = '%s.%s' % (self._mock_name, attr)
return _Call(name=name, parent=self, from_kall=False)
@ -2125,8 +2125,8 @@ class _Call(tuple):
return self.__getattr__('index')(*args, **kwargs)
def __repr__(self):
if not self.from_kall:
name = self.name or 'call'
if not self._mock_from_kall:
name = self._mock_name or 'call'
if name.startswith('()'):
name = 'call%s' % name
return name
@ -2152,9 +2152,9 @@ class _Call(tuple):
vals = []
thing = self
while thing is not None:
if thing.from_kall:
if thing._mock_from_kall:
vals.append(thing)
thing = thing.parent
thing = thing._mock_parent
return _CallList(reversed(vals))