[Zope-Checkins] CVS: Zope3/lib/python/Zope/Security/tests - testRestrictedInterpreter.py:1.1.2.3 test_Proxy.py:1.1.2.3
Guido van Rossum
guido@python.org
Thu, 18 Apr 2002 12:24:13 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv6073/tests
Modified Files:
Tag: SecurityProxy-branch
testRestrictedInterpreter.py test_Proxy.py
Log Message:
Wrap __str__. Strings and unicode are rocks.
=== Zope3/lib/python/Zope/Security/tests/testRestrictedInterpreter.py 1.1.2.2 => 1.1.2.3 ===
def proxy(self, value, checked):
return Proxy(value, self)
+ def __getattr__(self, name):
+ if name.startswith("check_"):
+ return lambda *args: None
+ else:
+ raise AttributeError, name
class RITests(unittest.TestCase):
=== Zope3/lib/python/Zope/Security/tests/test_Proxy.py 1.1.2.2 => 1.1.2.3 ===
def proxy(self, value, checked):
##print "proxy", (value, checked)
+ if isinstance(value, str):
+ return value
return [value, checked]
+ def __getattr__(self, name):
+ if name.startswith("check_"):
+ return lambda *args: None
+ else:
+ raise AttributeError, name
class Something:
- foo = "whatever"
+ foo = [1,2,3]
class ProxyTests(unittest.TestCase):
@@ -29,7 +36,7 @@
self.assertEqual(repr(self.p), repr(self.x))
def testGetAttrOK(self):
- self.assertEqual(self.p.foo, ["whatever", "hello"])
+ self.assertEqual(self.p.foo, [[1,2,3], "hello"])
def testGetAttrFail(self):
self.assertRaises(RuntimeError, lambda: self.p.bar)