[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Folder/tests - testFolderAdder.py:1.1.2.6

Jim Fulton jim@cvs.zope.org
Tue, 19 Feb 2002 11:05:38 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Folder/tests
In directory cvs.zope.org:/tmp/cvs-serv7148/lib/python/Zope/App/OFS/Folder/tests

Modified Files:
      Tag: Zope-3x-branch
	testFolderAdder.py 
Log Message:
Refactored tests to use a global-data cleanup framework.
This avoids a lot of messy clean-up code needed for tests that
use global registries, such as component services.

It is really important to make sure global registries get registered
with this framework.

See the doc strings in Zope.Testing.CleannUp.


=== Zope3/lib/python/Zope/App/OFS/Folder/tests/testFolderAdder.py 1.1.2.5 => 1.1.2.6 ===
 from Zope.App.ZMI.provideClass import provideClass
 from Zope.App.ZMI.Addable import ContentAddables
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
 
 class Foo: pass
 class Bar: pass
@@ -21,16 +22,7 @@
 
 AddPermission = []
 
-class RegistryTest( unittest.TestCase ):
-
-    def setUp( self ):
-        pass
-
-    def tearDown( self ):
-        from Zope.App.ZMI.Addable import _clear as clearAddables
-        from Zope.ComponentArchitecture import _clear as clearRegistry
-        clearAddables()
-        clearRegistry()
+class RegistryTest(CleanUp, unittest.TestCase):
 
     def testNonesuch( self ):
         """
@@ -107,9 +99,9 @@
         info_list = fa.listAddableInfo()
         self.assertEquals( len( info_list ), 3 )
 
-class AddingTest( unittest.TestCase ):
+class AddingTest(CleanUp, unittest.TestCase ):
 
-    def setUp( self ):
+    def setUp(self):
         provideClass(ContentAddables
                     , qualified_name='Zope.App.OFS.Folder'
                     , _class=Folder
@@ -117,13 +109,7 @@
                     , title='Folder'
                     )
 
-    def tearDown( self ):
-        from Zope.App.ZMI.Addable import _clear as clearAddables
-        from Zope.ComponentArchitecture import _clear as clearRegistry
-        clearAddables()
-        clearRegistry()
-
-    def testAdding( self ):
+    def testAdding(self):
         """
             Does addition of a new object with the same ID as an existing
             object fail?