[Zope-Checkins] CVS: Zope3/lib/python/Zope/Security/tests - test_Proxy.py:1.1.2.8

Guido van Rossum guido@python.org
Thu, 18 Apr 2002 15:05:00 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv2203

Modified Files:
      Tag: SecurityProxy-branch
	test_Proxy.py 
Log Message:
Check the new getitem/setitem.


=== Zope3/lib/python/Zope/Security/tests/test_Proxy.py 1.1.2.7 => 1.1.2.8 ===
 
     call_ok = 1
+    getitem_ok = 1
+    setitem_ok = 1
 
     def check_getattr(self, object, name):
         if name != "foo":
@@ -15,13 +17,13 @@
         if name != "foo":
             raise RuntimeError
 
-    def check_getitem(self, object, key):
-        if not 0 <= key < 10:
+    def check_getitem(self, object):
+        if not self.getitem_ok:
             raise RuntimeError
         return "hello"
 
-    def check_setitem(self, object, key):
-        if not 0 <= key < 10:
+    def check_setitem(self, object):
+        if not self.setitem_ok:
             raise RuntimeError
         return "hello"
 
@@ -83,6 +85,7 @@
         self.assertEqual(self.p[0], [1, "hello"])
 
     def testGetItemFail(self):
+        self.c.getitem_ok = 0
         def doit(): return self.p[10]
         self.assertRaises(RuntimeError, doit)
 
@@ -91,6 +94,7 @@
         self.assertEqual(self.p[0], [42, "hello"])
 
     def testSetItemFail(self):
+        self.c.setitem_ok = 0
         def doit(): self.p[10] = 42
         self.assertRaises(RuntimeError, doit)