[Zope-Checkins] CVS: Zope3/lib/python/Zope/Security/tests - test_Proxy.py:1.1.4.2
Jim Fulton
jim@zope.com
Tue, 21 May 2002 08:18:48 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv5183/Zope/Security/tests
Modified Files:
Tag: Zope-3x-branch
test_Proxy.py
Log Message:
Changed security proxies to fall back to a default str and repr when
the proxied object's str and repr are not accessable.
This makes error messages and diagnosis a bit saner.
=== Zope3/lib/python/Zope/Security/tests/test_Proxy.py 1.1.4.1 => 1.1.4.2 ===
def check_getattr(self, object, name):
- if name not in ("foo", "next"):
+ if name not in ("foo", "next", "__class__", "__name__", "__module__"):
raise RuntimeError
def check_setattr(self, object, name):
@@ -69,8 +69,29 @@
def testStr(self):
self.assertEqual(str(self.p), str(self.x))
+ x = Something()
+ c = Checker()
+ c.ok = 0
+ p = ProxyFactory(x, c)
+ s = str(p)
+ self.failUnless(s.startswith(
+ "<security proxied %s.%s instance at"
+ % (x.__class__.__module__, x.__class__.__name__)),
+ s)
+
+
def testRepr(self):
self.assertEqual(repr(self.p), repr(self.x))
+
+ x = Something()
+ c = Checker()
+ c.ok = 0
+ p = ProxyFactory(x, c)
+ s = repr(p)
+ self.failUnless(s.startswith(
+ "<security proxied %s.%s instance at"
+ % (x.__class__.__module__, x.__class__.__name__)),
+ s)
def testGetAttrOK(self):
self.assertEqual(getObject(self.p.foo), [1,2,3])