[Zope3-checkins] CVS: Zope3/src/zope/proxy/tests - test_proxy.py:1.15

Jim Fulton jim at zope.com
Sun Sep 21 13:34:27 EDT 2003


Update of /cvs-repository/Zope3/src/zope/proxy/tests
In directory cvs.zope.org:/tmp/cvs-serv16044/src/zope/proxy/tests

Modified Files:
	test_proxy.py 
Log Message:
Added support for descriptors in proxy subclasses.


=== Zope3/src/zope/proxy/tests/test_proxy.py 1.14 => 1.15 ===
--- Zope3/src/zope/proxy/tests/test_proxy.py:1.14	Tue Jul  1 19:26:38 2003
+++ Zope3/src/zope/proxy/tests/test_proxy.py	Sun Sep 21 13:34:26 2003
@@ -513,6 +513,43 @@
     0
     """
 
+def test_subclassing_proxies():
+    """You can subclass ProxyBase
+
+    If you subclass a proxy, instances of the subclass have access to
+    data defined in the class, including descriptors.
+
+    Your subclass instances don't get instance dictionaries, but they
+    can have slots.
+
+    >>> class MyProxy(ProxyBase):
+    ...    __slots__ = 'x', 'y'
+    ...
+    ...    def f(self):
+    ...        return self.x
+
+    >>> l = [1, 2, 3]
+    >>> p = MyProxy(l)
+
+    I can use attributes defined by the class, including slots:
+    
+    >>> p.x = 'x'
+    >>> p.x
+    'x'
+    >>> p.f()
+    'x'
+
+    I can also use attributes of the proxied object:
+    
+    >>> p
+    [1, 2, 3]
+    >>> p.pop()
+    3
+    >>> p
+    [1, 2]
+    
+    """
+
 
 def test_suite():
     suite = unittest.makeSuite(ProxyTestCase)




More information about the Zope3-Checkins mailing list