[Checkins] SVN: zope.proxy/trunk/ Restore tests for lying about '__class__' in pure Python.
Tres Seaver
cvs-admin at zope.org
Wed Jun 6 20:42:38 UTC 2012
Log message for revision 126629:
Restore tests for lying about '__class__' in pure Python.
Now that we have the gnarly '__getattribute__', we *can* tell that lie.
Changed:
_U zope.proxy/trunk/
U zope.proxy/trunk/src/zope/proxy/__init__.py
U zope.proxy/trunk/src/zope/proxy/tests/test_proxy.py
-=-
Modified: zope.proxy/trunk/src/zope/proxy/__init__.py
===================================================================
--- zope.proxy/trunk/src/zope/proxy/__init__.py 2012-06-06 20:13:32 UTC (rev 126628)
+++ zope.proxy/trunk/src/zope/proxy/__init__.py 2012-06-06 20:42:35 UTC (rev 126629)
@@ -58,7 +58,7 @@
def __unicode__(self):
return unicode(self._wrapped)
- def __reduce__(self):
+ def __reduce__(self): #pragma NO COVER (__reduce_ex__ prevents normal)
raise pickle.PicklingError
def __reduce_ex__(self, proto):
@@ -100,7 +100,7 @@
except AttributeError:
mine = _MARKER
else:
- if isinstance(mine, PyNonOverridable):
+ if isinstance(mine, PyNonOverridable): #pragma NO COVER PyPy
return mine.desc.__get__(self)
try:
return getattr(wrapped, name)
@@ -413,7 +413,7 @@
return obj
class PyNonOverridable(object):
- def __init__(self, method_desc):
+ def __init__(self, method_desc): #pragma NO COVER PyPy
self.desc = method_desc
try:
Modified: zope.proxy/trunk/src/zope/proxy/tests/test_proxy.py
===================================================================
--- zope.proxy/trunk/src/zope/proxy/tests/test_proxy.py 2012-06-06 20:13:32 UTC (rev 126628)
+++ zope.proxy/trunk/src/zope/proxy/tests/test_proxy.py 2012-06-06 20:42:35 UTC (rev 126629)
@@ -179,6 +179,15 @@
w1 = self._makeOne(1)
self.assertEqual(hash(w1), hash(1))
+ def test___getattr__miss_both(self):
+ class Foo(object):
+ pass
+ o = Foo()
+ w = self._makeOne(o)
+ def _try():
+ return w.nonesuch
+ self.assertRaises(AttributeError, _try)
+
def test___getattr__delegates_to_wrapped(self):
class Foo(object):
pass
@@ -534,25 +543,19 @@
self.assertEqual(a, float(x))
self.assertTrue(b is y)
+ def test___class__(self):
+ o = object()
+ w = self._makeOne(o)
+ self.assertTrue(w.__class__ is o.__class__)
+
class ProxyBaseTestCase(PyProxyBaseTestCase):
def _getTargetClass(self):
from zope.proxy import ProxyBase
return ProxyBase
- def test___class__(self):
- try:
- from zope.proxy import _CAPI
- except ImportError:
- # Pure Python proxies can't lie about their '__class__'
- pass
- else:
- o = object()
- w = self._makeOne(o)
- self.assertTrue(w.__class__ is o.__class__)
-
class Test_py_getProxiedObject(unittest.TestCase):
def _callFUT(self, *args):
More information about the checkins
mailing list