[Zope3-checkins] CVS: Zope3/src/zope/app/rdb/tests - test_row.py:1.4
Steve Alexander
steve@cat-box.net
Mon, 9 Jun 2003 11:31:58 -0400
Update of /cvs-repository/Zope3/src/zope/app/rdb/tests
In directory cvs.zope.org:/tmp/cvs-serv718/src/zope/app/rdb/tests
Modified Files:
test_row.py
Log Message:
Some minor stylistic cleanups.
Created an InstanceOnlyDescriptor to fix the problem of a
__Security_checker__ attribute of a class, intended for its instances
only, also acting for the class.
The InstanceOnlyDescriptor may be more generally applicable. It is written
and tested to act as a complete data descriptor, that is more than strictly
the minimum needed for this module. Perhaps it should be moved elsewhere?
=== Zope3/src/zope/app/rdb/tests/test_row.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/rdb/tests/test_row.py:1.3 Thu May 1 15:35:30 2003
+++ Zope3/src/zope/app/rdb/tests/test_row.py Mon Jun 9 11:31:57 2003
@@ -49,9 +49,9 @@
self.failUnless (proxied.type == 'airplane', "security proxy error")
self.failUnless (proxied.speed == '800km', "security proxy error (2)")
- self.assertRaises(ForbiddenAttribute,
- lambda x=proxied: x.__slots__
- )
+ self.assertRaises(ForbiddenAttribute, getattr, proxied, '__slots__')
+ proxied_class = ProxyFactory(klass)
+ proxied_class.__bases__
def test__cmp__(self):
from zope.app.rdb import RowClassFactory
@@ -81,6 +81,23 @@
ob4 = klass4(data)
self.assert_(ob < ob4, "cmp with different data")
+ def test_InstanceOnlyDescriptor(self):
+ from zope.app.rdb import InstanceOnlyDescriptor
+ inst = object() # could be anything
+ cls = object # could be any class
+ d = InstanceOnlyDescriptor()
+ self.assertRaises(AttributeError, d.__get__, inst, cls)
+ self.assertRaises(AttributeError, d.__get__, None, cls)
+ self.assertRaises(AttributeError, d.__delete__, inst)
+ d.__set__(inst, 23)
+ self.assertEquals(d.__get__(inst, cls), 23)
+ self.assertRaises(AttributeError, d.__get__, None, cls)
+ d = InstanceOnlyDescriptor(23)
+ self.assertEquals(d.__get__(inst, cls), 23)
+ d.__delete__(inst)
+ self.assertRaises(AttributeError, d.__get__, inst, cls)
+ self.assertRaises(AttributeError, d.__get__, None, cls)
+ self.assertRaises(AttributeError, d.__delete__, inst)
def test_suite():