Commit 9776b119 authored by Tres Seaver's avatar Tres Seaver

- Unscrew order-of-testing problem, caused by use of 'newSecurityManger'

   in 'setUp' without corresponding 'noSecurityManager' in teardown.
parent 4b1c5622
...@@ -9,6 +9,7 @@ from Testing.makerequest import makerequest ...@@ -9,6 +9,7 @@ from Testing.makerequest import makerequest
from webdav.common import rfc1123_date from webdav.common import rfc1123_date
from AccessControl import SecurityManager from AccessControl import SecurityManager
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from mimetools import Message from mimetools import Message
from multifile import MultiFile from multifile import MultiFile
...@@ -46,32 +47,29 @@ class UnitTestUser( Acquisition.Implicit ): ...@@ -46,32 +47,29 @@ class UnitTestUser( Acquisition.Implicit ):
def allowed( self, object, object_roles=None ): def allowed( self, object, object_roles=None ):
return 1 return 1
_CONNECTION = None
_ROOT = None
_APP = None
def makeConnection(): def makeConnection():
import ZODB
from ZODB.DemoStorage import DemoStorage
global _CONNECTION s = DemoStorage(quota=(1<<20))
global _ROOT return ZODB.DB( s ).open()
global _APP
if not _CONNECTION: class TestCopySupport( unittest.TestCase ):
import ZODB
from ZODB.DemoStorage import DemoStorage def setUp( self ):
responseOut = cStringIO.StringIO()
s = DemoStorage(quota=(1<<20)) self.connection = makeConnection()
_CONNECTION = ZODB.DB( s ).open()
try: try:
r = _CONNECTION.root() r = self.connection.root()
a = Application() a = Application()
r['Application'] = a r['Application'] = a
_ROOT = a self.root = a
_APP = makerequest( _ROOT, stdout=responseOut ) responseOut = self.responseOut = cStringIO.StringIO()
manage_addFolder( _APP, 'folder1' ) self.app = makerequest( self.root, stdout=responseOut )
manage_addFolder( _APP, 'folder2' ) manage_addFolder( self.app, 'folder1' )
folder1 = getattr( _APP, 'folder1' ) manage_addFolder( self.app, 'folder2' )
folder2 = getattr( _APP, 'folder2' ) folder1 = getattr( self.app, 'folder1' )
folder2 = getattr( self.app, 'folder2' )
folder1.all_meta_types = folder2.all_meta_types = \ folder1.all_meta_types = folder2.all_meta_types = \
( { 'name' : 'File' ( { 'name' : 'File'
...@@ -89,16 +87,8 @@ def makeConnection(): ...@@ -89,16 +87,8 @@ def makeConnection():
# later and pretend we didn't touch the ZODB. # later and pretend we didn't touch the ZODB.
get_transaction().commit() get_transaction().commit()
except: except:
_CONNECTION.close() self.connection.close()
raise raise
return _CONNECTION, _ROOT, _APP
class TestCopySupport( unittest.TestCase ):
def setUp( self ):
self.connection, self.root, self.app = makeConnection()
get_transaction().begin() get_transaction().begin()
self.folder1 = getattr( self.app, 'folder1' ) self.folder1 = getattr( self.app, 'folder1' )
self.folder2 = getattr( self.app, 'folder2' ) self.folder2 = getattr( self.app, 'folder2' )
...@@ -108,11 +98,15 @@ class TestCopySupport( unittest.TestCase ): ...@@ -108,11 +98,15 @@ class TestCopySupport( unittest.TestCase ):
newSecurityManager( None, UnitTestUser().__of__( self.root ) ) newSecurityManager( None, UnitTestUser().__of__( self.root ) )
def tearDown( self ): def tearDown( self ):
noSecurityManager()
del self.policy del self.policy
del self.folder1
del self.folder2 del self.folder2
del self.folder1
get_transaction().abort() get_transaction().abort()
self.app._p_jar.sync()
self.connection.close()
del self.app del self.app
del self.responseOut
del self.root del self.root
del self.connection del self.connection
......
...@@ -99,9 +99,6 @@ def makeConnection(): ...@@ -99,9 +99,6 @@ def makeConnection():
import ZODB import ZODB
from ZODB.DemoStorage import DemoStorage from ZODB.DemoStorage import DemoStorage
dfi = os.path.join( os.environ['SOFTWARE_HOME']
, '..', '..', 'var', 'Data.fs.in')
dfi = os.path.abspath(dfi)
s = DemoStorage(quota=(1<<20)) s = DemoStorage(quota=(1<<20))
return ZODB.DB( s ).open() return ZODB.DB( s ).open()
...@@ -155,7 +152,8 @@ class TestRequestRange(unittest.TestCase): ...@@ -155,7 +152,8 @@ class TestRequestRange(unittest.TestCase):
def tearDown(self): def tearDown(self):
try: self.app._delObject(TESTFOLDER_NAME) try: self.app._delObject(TESTFOLDER_NAME)
except AttributeError: pass except AttributeError: pass
get_transaction().commit() get_transaction().abort()
self.app._p_jar.sync()
self.connection.close() self.connection.close()
self.app = None self.app = None
del self.app del self.app
......
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