[CMF-checkins]
SVN: CMF/branches/2.0/CMFCore/tests/test_FSPropertiesObject.py
Test cleanup:
Tres Seaver
tseaver at palladion.com
Fri Sep 8 12:57:07 EDT 2006
Log message for revision 70071:
Test cleanup:
- Don't import module-under-test at module scope.
- Don't do the Zope2.startup() dance.
- Just 'import unittest'.
- Remove useless baseclass.
- Avoid setting attributes on the testcase in 'setUp'; instead, pass
the needed values back from a helper method.
Changed:
U CMF/branches/2.0/CMFCore/tests/test_FSPropertiesObject.py
-=-
Modified: CMF/branches/2.0/CMFCore/tests/test_FSPropertiesObject.py
===================================================================
--- CMF/branches/2.0/CMFCore/tests/test_FSPropertiesObject.py 2006-09-08 15:05:47 UTC (rev 70070)
+++ CMF/branches/2.0/CMFCore/tests/test_FSPropertiesObject.py 2006-09-08 16:57:07 UTC (rev 70071)
@@ -1,60 +1,60 @@
-from unittest import TestSuite, makeSuite, main
-import Testing
-import Zope2
-Zope2.startup()
+import unittest
from os.path import join
from OFS.Folder import Folder
-from Products.CMFCore.FSPropertiesObject import FSPropertiesObject
from Products.CMFCore.tests.base.testcase import FSDVTest
from Products.CMFCore.tests.base.testcase import SecurityTest
+class FSPOTests(SecurityTest, FSDVTest):
-class FSPOMaker(FSDVTest):
+ def setUp( self ):
+ FSDVTest.setUp(self)
+ SecurityTest.setUp( self )
+ def tearDown( self ):
+ SecurityTest.tearDown( self )
+ FSDVTest.tearDown(self)
+
+ def _getTargetClass( self ):
+ from Products.CMFCore.FSPropertiesObject import FSPropertiesObject
+ return FSPropertiesObject
+
def _makeOne( self, id, filename ):
path = join(self.skin_path_name, filename)
- return FSPropertiesObject( id, path )
+ return self._getTargetClass()( id, path )
-
-class FSPropertiesObjectCustomizationTests(SecurityTest, FSPOMaker):
-
- def setUp( self ):
- FSPOMaker.setUp(self)
- SecurityTest.setUp( self )
-
+ def _makeContext( self, po_id, po_filename ):
self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
- self.skins = self.root.portal_skins
+ skins = self.root.portal_skins
- self.skins._setObject( 'custom', Folder( 'custom' ) )
- self.custom = self.skins.custom
+ skins._setObject( 'custom', Folder( 'custom' ) )
+ custom = skins.custom
- self.skins._setObject( 'fsdir', Folder( 'fsdir' ) )
- self.fsdir = self.skins.fsdir
+ skins._setObject( 'fsdir', Folder( 'fsdir' ) )
+ fsdir = skins.fsdir
- self.fsdir._setObject( 'test_props'
- , self._makeOne( 'test_props', 'test_props.props' ) )
+ fsdir._setObject( 'test_props', self._makeOne( po_id, po_filename ) )
+ fspo = fsdir.test_props
- self.fsPO = self.fsdir.test_props
+ return custom, fsdir, fspo
- def tearDown(self):
- SecurityTest.tearDown(self)
- FSPOMaker.tearDown(self)
-
def test_customize( self ):
- self.fsPO.manage_doCustomize( folder_path='custom' )
+ custom, fsdir, fspo = self._makeContext( 'test_props'
+ , 'test_props.props')
- self.assertEqual( len( self.custom.objectIds() ), 1 )
- self.failUnless( 'test_props' in self.custom.objectIds() )
+ fspo.manage_doCustomize( folder_path='custom' )
+ self.assertEqual( len( custom.objectIds() ), 1 )
+ self.failUnless( 'test_props' in custom.objectIds() )
+
def test_suite():
- return TestSuite((
- makeSuite(FSPropertiesObjectCustomizationTests),
+ return unittest.TestSuite((
+ unittest.makeSuite( FSPOTests ),
))
if __name__ == '__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
More information about the CMF-checkins
mailing list