[Zope-Checkins] SVN: Zope/trunk/lib/python/AccessControl/tests/testZopeGuards.py Make test actually exercise guards in Python 2.5.

Tres Seaver tseaver at palladion.com
Mon Oct 27 16:34:07 EDT 2008


Log message for revision 92632:
  Make test actually exercise guards in Python 2.5.

Changed:
  U   Zope/trunk/lib/python/AccessControl/tests/testZopeGuards.py

-=-
Modified: Zope/trunk/lib/python/AccessControl/tests/testZopeGuards.py
===================================================================
--- Zope/trunk/lib/python/AccessControl/tests/testZopeGuards.py	2008-10-27 20:30:03 UTC (rev 92631)
+++ Zope/trunk/lib/python/AccessControl/tests/testZopeGuards.py	2008-10-27 20:34:06 UTC (rev 92632)
@@ -307,8 +307,11 @@
         self.assertRaises(Unauthorized, guarded_min, [1,2,3])
         self.assertRaises(Unauthorized, guarded_min, 1,2,3)
         if MIN_MAX_TAKE_KEY:
+            class MyDict(dict):  # guard() skips 'dict' values
+                pass
             self.assertRaises(Unauthorized, guarded_min,
-                              [{'x':1},{'x':2}], operator.itemgetter('x'))
+                              MyDict(x=1), MyDict(x=2),
+                              key=operator.itemgetter('x'))
         self.setSecurityManager(old)
 
     def test_max_fails(self):
@@ -319,8 +322,11 @@
         self.assertRaises(Unauthorized, guarded_max, [1,2,3])
         self.assertRaises(Unauthorized, guarded_max, 1,2,3)
         if MIN_MAX_TAKE_KEY:
+            class MyDict(dict):  # guard() skips 'dict' values
+                pass
             self.assertRaises(Unauthorized, guarded_max, 
-                            [{'x':1},{'x':2}], operator.itemgetter('x'))
+                              MyDict(x=1), MyDict(x=2),
+                              key=operator.itemgetter('x'))
         self.setSecurityManager(old)
 
     def test_enumerate_fails(self):
@@ -377,7 +383,9 @@
         self.assertEqual(guarded_min([1,2,3]), 1)
         self.assertEqual(guarded_min(1,2,3), 1)
         if MIN_MAX_TAKE_KEY:
-            self.assertEqual(guarded_min({'x':1},{'x':2}, 
+            class MyDict(dict):  # guard() skips 'dict' values
+                pass
+            self.assertEqual(guarded_min(MyDict(x=1), MyDict(x=2),
                                          key=operator.itemgetter('x')),
                              {'x':1})
         self.setSecurityManager(old)
@@ -389,7 +397,9 @@
         self.assertEqual(guarded_max([1,2,3]), 3)
         self.assertEqual(guarded_max(1,2,3), 3)
         if MIN_MAX_TAKE_KEY:
-            self.assertEqual(guarded_max({'x':1},{'x':2}, 
+            class MyDict(dict):  # guard() skips 'dict' values
+                pass
+            self.assertEqual(guarded_max(MyDict(x=1), MyDict(x=2),
                                          key=operator.itemgetter('x')),
                              {'x':2})
         self.setSecurityManager(old)



More information about the Zope-Checkins mailing list