[Checkins] SVN: Zope/trunk/src/Products/Five/tests/testing/restricted.py Small cleanup

Hanno Schlichting hannosch at hannosch.eu
Sat Jul 10 07:20:10 EDT 2010


Log message for revision 114504:
  Small cleanup
  

Changed:
  U   Zope/trunk/src/Products/Five/tests/testing/restricted.py

-=-
Modified: Zope/trunk/src/Products/Five/tests/testing/restricted.py
===================================================================
--- Zope/trunk/src/Products/Five/tests/testing/restricted.py	2010-07-10 11:15:54 UTC (rev 114503)
+++ Zope/trunk/src/Products/Five/tests/testing/restricted.py	2010-07-10 11:20:10 UTC (rev 114504)
@@ -16,28 +16,29 @@
 Based on Plone's RestrictedPythonTestCase, with kind permission by the
 Plone developers.
 """
+
 from AccessControl import Unauthorized
+from Products.PythonScripts.PythonScript import manage_addPythonScript
 
+
 def addPythonScript(folder, id, params='', body=''):
     """Add a PythonScript to folder."""
     # clean up any 'ps' that's already here..
-    try:
-        folder._getOb(id)
-        folder.manage_delObjects([id])
-    except AttributeError:
-        pass # it's okay, no 'ps' exists yet
-    factory = folder.manage_addProduct['PythonScripts']
-    factory.manage_addPythonScript(id)
+    if id in folder:
+        del folder[id]
+    manage_addPythonScript(folder, id)
     folder[id].ZPythonScript_edit(params, body)
 
+
 def checkRestricted(folder, psbody):
     """Perform a check by running restricted Python code."""
     addPythonScript(folder, 'ps', body=psbody)
     try:
         folder.ps()
     except Unauthorized, e:
-        raise AssertionError, e
+        raise AssertionError(e)
 
+
 def checkUnauthorized(folder, psbody):
     """Perform a check by running restricted Python code.  Expect to
     encounter an Unauthorized exception."""
@@ -47,4 +48,4 @@
     except Unauthorized:
         pass
     else:
-        raise AssertionError, "Authorized but shouldn't be"
+        raise AssertionError("Authorized but shouldn't be")



More information about the checkins mailing list