[Zope-Checkins] CVS: Zope/lib/python/OFS/tests - testCopySupport.py:1.2 testRanges.py:1.8
Tres Seaver
tseaver@zope.com
Fri, 9 Nov 2001 14:34:42 -0500
Update of /cvs-repository/Zope/lib/python/OFS/tests
In directory cvs.zope.org:/tmp/cvs-serv32080/lib/python/OFS/tests
Modified Files:
testCopySupport.py testRanges.py
Log Message:
- Unscrew order-of-testing problem, caused by use of 'newSecurityManger'
in 'setUp' without corresponding 'noSecurityManager' in teardown.
=== Zope/lib/python/OFS/tests/testCopySupport.py 1.1 => 1.2 ===
from AccessControl import SecurityManager
from AccessControl.SecurityManagement import newSecurityManager
+from AccessControl.SecurityManagement import noSecurityManager
from mimetools import Message
from multifile import MultiFile
@@ -46,32 +47,29 @@
def allowed( self, object, object_roles=None ):
return 1
-_CONNECTION = None
-_ROOT = None
-_APP = None
-
def makeConnection():
+ import ZODB
+ from ZODB.DemoStorage import DemoStorage
+
+ s = DemoStorage(quota=(1<<20))
+ return ZODB.DB( s ).open()
- global _CONNECTION
- global _ROOT
- global _APP
-
- if not _CONNECTION:
- import ZODB
- from ZODB.DemoStorage import DemoStorage
- responseOut = cStringIO.StringIO()
- s = DemoStorage(quota=(1<<20))
- _CONNECTION = ZODB.DB( s ).open()
+class TestCopySupport( unittest.TestCase ):
+
+ def setUp( self ):
+
+ self.connection = makeConnection()
try:
- r = _CONNECTION.root()
+ r = self.connection.root()
a = Application()
r['Application'] = a
- _ROOT = a
- _APP = makerequest( _ROOT, stdout=responseOut )
- manage_addFolder( _APP, 'folder1' )
- manage_addFolder( _APP, 'folder2' )
- folder1 = getattr( _APP, 'folder1' )
- folder2 = getattr( _APP, 'folder2' )
+ self.root = a
+ responseOut = self.responseOut = cStringIO.StringIO()
+ self.app = makerequest( self.root, stdout=responseOut )
+ manage_addFolder( self.app, 'folder1' )
+ manage_addFolder( self.app, 'folder2' )
+ folder1 = getattr( self.app, 'folder1' )
+ folder2 = getattr( self.app, 'folder2' )
folder1.all_meta_types = folder2.all_meta_types = \
( { 'name' : 'File'
@@ -89,16 +87,8 @@
# later and pretend we didn't touch the ZODB.
get_transaction().commit()
except:
- _CONNECTION.close()
+ self.connection.close()
raise
-
- return _CONNECTION, _ROOT, _APP
-
-class TestCopySupport( unittest.TestCase ):
-
- def setUp( self ):
-
- self.connection, self.root, self.app = makeConnection()
get_transaction().begin()
self.folder1 = getattr( self.app, 'folder1' )
self.folder2 = getattr( self.app, 'folder2' )
@@ -108,11 +98,15 @@
newSecurityManager( None, UnitTestUser().__of__( self.root ) )
def tearDown( self ):
+ noSecurityManager()
del self.policy
- del self.folder1
del self.folder2
+ del self.folder1
get_transaction().abort()
+ self.app._p_jar.sync()
+ self.connection.close()
del self.app
+ del self.responseOut
del self.root
del self.connection
=== Zope/lib/python/OFS/tests/testRanges.py 1.7 => 1.8 ===
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))
return ZODB.DB( s ).open()
@@ -155,7 +152,8 @@
def tearDown(self):
try: self.app._delObject(TESTFOLDER_NAME)
except AttributeError: pass
- get_transaction().commit()
+ get_transaction().abort()
+ self.app._p_jar.sync()
self.connection.close()
self.app = None
del self.app