Commit 9b54c26e authored by Florent Guillaume's avatar Florent Guillaume

Run standalone, and do proper setup/teardown.

parent 9a6cedc8
...@@ -3,12 +3,16 @@ import unittest ...@@ -3,12 +3,16 @@ import unittest
from AccessControl.Owned import EmergencyUserCannotOwn from AccessControl.Owned import EmergencyUserCannotOwn
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.User import User # before SpecialUsers
from AccessControl.SpecialUsers import emergency_user, nobody, system from AccessControl.SpecialUsers import emergency_user, nobody, system
from AccessControl.User import User
from Acquisition import Implicit from Acquisition import Implicit
from App.config import getConfiguration from App.config import getConfiguration
from OFS.ObjectManager import ObjectManager from OFS.ObjectManager import ObjectManager
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from zope.app.testing.placelesssetup import PlacelessSetup
import Products.Five
from Products.Five import zcml
from Products.Five.eventconfigure import setDeprecatedManageAddDelete
class FauxRoot( Implicit ): class FauxRoot( Implicit ):
...@@ -53,23 +57,26 @@ class ItemForDeletion(SimpleItem): ...@@ -53,23 +57,26 @@ class ItemForDeletion(SimpleItem):
def manage_afterClone(self, item): def manage_afterClone(self, item):
pass pass
from Products.Five.eventconfigure import setDeprecatedManageAddDelete
setDeprecatedManageAddDelete(ItemForDeletion)
from zope.interface import implements from zope.interface import implements
from OFS.interfaces import IItem from OFS.interfaces import IItem
class ObjectManagerWithIItem(ObjectManager): class ObjectManagerWithIItem(ObjectManager):
"""The event subscribers work on IItem.""" """The event subscribers work on IItem."""
implements(IItem) implements(IItem)
class ObjectManagerTests( unittest.TestCase ): class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
def setUp(self): def setUp(self):
super(ObjectManagerTests, self).setUp()
self.saved_cfg_debug_mode = getConfiguration().debug_mode self.saved_cfg_debug_mode = getConfiguration().debug_mode
zcml.load_config('meta.zcml', Products.Five)
zcml.load_config('event.zcml', Products.Five)
zcml.load_config('deprecated.zcml', Products.Five)
setDeprecatedManageAddDelete(ItemForDeletion)
def tearDown( self ): def tearDown( self ):
noSecurityManager() noSecurityManager()
getConfiguration().debug_mode = self.saved_cfg_debug_mode getConfiguration().debug_mode = self.saved_cfg_debug_mode
super(ObjectManagerTests, self).tearDown()
def setDebugMode(self, mode): def setDebugMode(self, mode):
getConfiguration().debug_mode = mode getConfiguration().debug_mode = mode
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment