Skip to content

Commit

Permalink
I think I fixed some tests. Tres, can you review?
Browse files Browse the repository at this point in the history
  • Loading branch information
strichter committed Mar 8, 2013
1 parent 950ca7a commit a056283
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/zope/security/proxy.py
Expand Up @@ -23,7 +23,6 @@

def _check_name(meth):
name = meth.__name__
func = meth.__func__
def _wrapper(self, *args, **kw):
wrapped = super(PyProxyBase, self).__getattribute__('_wrapped')
checker = super(PyProxyBase, self).__getattribute__('_checker')
Expand All @@ -33,14 +32,15 @@ def _wrapper(self, *args, **kw):

def _check_name_inplace(meth):
name = meth.__name__
func = meth.__func__
def _wrapper(self, *args, **kw):
wrapped = super(PyProxyBase, self).__getattribute__('_wrapped')
checker = super(PyProxyBase, self).__getattribute__('_checker')
checker.check_getattr(wrapped, name)
w_meth = getattr(wrapped, name, None)
if w_meth is not None:
return w_meth(*args, **kw)
# The proxy object cannot change; we are modifying in place.
self._wrapped = w_meth(*args, **kw)
return self
x_name = '__%s__' % name[3:-2]
return ProxyPy(getattr(wrapped, x_name)(*args, **kw), checker)
return functools.update_wrapper(_wrapper, meth)
Expand Down
2 changes: 1 addition & 1 deletion src/zope/security/tests/test_proxy.py
Expand Up @@ -1082,8 +1082,8 @@ def test___ixor___not_inplace_checker_allows(self):
proxy = before = self._makeOne(target, checker)
proxy ^= 3
self.assertFalse(proxy is before)
self.assertEqual(proxy, 4)
self.assertEqual(checker._checked, '__ixor__')
self.assertEqual(proxy, 4)

def test___ixor___inplace_checker_allows(self):
class Foo(object):
Expand Down

0 comments on commit a056283

Please sign in to comment.