[Zope3-checkins] CVS: Zope3/src/zope/app/tests - test_context.py:1.6

Garrett Smith garrett at mojave-corp.com
Fri Aug 15 16:50:26 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/tests
In directory cvs.zope.org:/tmp/cvs-serv6308/src/zope/app/tests

Modified Files:
	test_context.py 
Log Message:
Modified the arguments for ForbiddenAttribute to include the object whose attribute is forbidden. 

=== Zope3/src/zope/app/tests/test_context.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/tests/test_context.py:1.5	Tue Jul  1 19:28:42 2003
+++ Zope3/src/zope/app/tests/test_context.py	Fri Aug 15 15:49:52 2003
@@ -24,6 +24,7 @@
 from zope.interface import Interface, implements, directlyProvides, providedBy
 from zope.interface import directlyProvidedBy, implementedBy
 from zope.testing.doctestunit import DocTestSuite
+from zope.exceptions import ForbiddenAttribute
 
 class I1(Interface):
     pass
@@ -40,6 +41,14 @@
 class D2(Wrapper):
   implements(I2)
 
+
+def check_forbidden_call(callable, *args):
+    try:
+        return callable(*args)
+    except ForbiddenAttribute, e:
+        return 'ForbiddenAttribute: %s' % e[0]
+
+
 def test_providedBy_iter_w_new_style_class():
     """
     >>> class X(object):
@@ -321,14 +330,10 @@
     <class 'zope.security.checker.Checker'>
     >>> c.check_getattr(w, 'a')
 
-    >>> c.check_getattr(w, 'b')
-    Traceback (most recent call last):
-    ...
-    ForbiddenAttribute: b
-    >>> c.check_getattr(w, 'c')
-    Traceback (most recent call last):
-    ...
-    ForbiddenAttribute: c
+    >>> check_forbidden_call(c.check_getattr, w, 'b')
+    'ForbiddenAttribute: b'
+    >>> check_forbidden_call(c.check_getattr, w, 'c')
+    'ForbiddenAttribute: c'
 
     >>> class MyWrapper2(Wrapper):
     ...     __Security_checker__ = DecoratedSecurityCheckerDescriptor()
@@ -341,10 +346,8 @@
 
     >>> c.check_getattr(w, 'b')
 
-    >>> c.check_getattr(w, 'c')
-    Traceback (most recent call last):
-    ...
-    ForbiddenAttribute: c
+    >>> check_forbidden_call(c.check_getattr, w, 'c')
+    'ForbiddenAttribute: c'
 
     >>> w = MyWrapper(None)
     >>> int(w.__Security_checker__ is None)




More information about the Zope3-Checkins mailing list