[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZMI/tests - testAddable.py:1.1.2.4 testProvideClass.py:1.1.2.4 testServiceProvideClass.py:1.1.2.4 testTabsDirective.py:1.1.2.5 testZMIViewService.py:1.1.2.4 testZMIViewUtility.py:1.1.2.6

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


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

Modified Files:
      Tag: Zope-3x-branch
	testAddable.py testProvideClass.py testServiceProvideClass.py 
	testTabsDirective.py testZMIViewService.py 
	testZMIViewUtility.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/ZMI/tests/testAddable.py 1.1.2.3 => 1.1.2.4 ===
 
 import unittest, sys
-from Zope.App.ZMI.Addable import ContentAddables, _clear, Addable
+from Zope.App.ZMI.Addable import ContentAddables, Addable
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
 
-class Test(unittest.TestCase):
-
-    def tearDown(self):
-        _clear()
+class Test(CleanUp, unittest.TestCase):
 
     def testItAll(self):
 


=== Zope3/lib/python/Zope/App/ZMI/tests/testProvideClass.py 1.1.2.3 => 1.1.2.4 ===
 
 import unittest, sys, Interface
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
 
 
 class MyAddableObject:
     pass
 
-class ProvideClassTest(unittest.TestCase):
-
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        from Zope.App.ZMI.Addable import _clear
-        _clear()
-        from Zope.ComponentArchitecture import _clear
-        _clear()
+class ProvideClassTest(CleanUp, unittest.TestCase):
 
     def testProvideClass(self):
         from Zope.ComponentArchitecture.hooks import createObject


=== Zope3/lib/python/Zope/App/ZMI/tests/testServiceProvideClass.py 1.1.2.3 => 1.1.2.4 ===
 from StringIO import StringIO
 from Zope.Configuration.xmlconfig import xmlconfig
-from Zope.Configuration.meta import _clear as metaclear
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
 from Zope.Configuration.xmlconfig import ZopeXMLConfigurationError
 
 
@@ -30,21 +30,11 @@
 class MyAddableService:
     pass
 
-class ServiceProvideClassTest(unittest.TestCase):
-
-    def setUp(self):
-        ServiceAddables._clear()
-
-    def tearDown(self):
-        from Zope.App.ZMI.Addable import _clear
-        _clear()
-        from Zope.ComponentArchitecture import _clear
-        _clear()
-
+class ServiceProvideClassTest(CleanUp, unittest.TestCase):
 
     def testServiceProvideClassDirective(self):
-        serviceName = \
-            'Zope.App.ZMI.tests.testServiceProvideClass.MyAddableService'
+        serviceName = (
+            'Zope.App.ZMI.tests.testServiceProvideClass.MyAddableService')
         
         xmlconfig( StringIO("""
         <zopeConfigure


=== Zope3/lib/python/Zope/App/ZMI/tests/testTabsDirective.py 1.1.2.4 => 1.1.2.5 ===
 
 from Zope.App.ZMI.ZMIViewService import ZMIViews
-from Zope.ComponentArchitecture import provideAdapter, _clear
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.ComponentArchitecture import provideAdapter
 from Zope.Configuration.xmlconfig import xmlconfig
-from Zope.Configuration.meta import _clear as metaclear
 from Zope.Configuration.xmlconfig import ZopeXMLConfigurationError
 
 from Interface import Interface
@@ -31,17 +31,9 @@
 from Zope.App.ZMI.tests.sampleInterfaces import *
 
 
-class Test(unittest.TestCase):
+class Test(CleanUp, unittest.TestCase):
     #XXX we should have a test for multiple inheritance interface
     # hierarchies.
-
-    def tearDown(self):
-        _clear()
-        ZMIViews._clear()        
-
-    def tearDown(self):
-        metaclear()
-        ZMIViews._clear()
 
     def testZMITabDirective(self):
         xmlconfig( StringIO("""


=== Zope3/lib/python/Zope/App/ZMI/tests/testZMIViewService.py 1.1.2.3 => 1.1.2.4 ===
 from Interface import Interface
 
-from Zope.ComponentArchitecture import provideAdapter, _clear
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.ComponentArchitecture import provideAdapter
 from Zope.App.ZMI.ZMIViewService import ZMIViewService
 from Zope.App.ZMI.tests.sampleInterfaces import *
 
 
 
-class Test(unittest.TestCase):
+class Test(CleanUp, unittest.TestCase):
     #XXX we should have a test for multiple inheritance interface
     # hierarchies.
-
-    def tearDown(self):
-        _clear()
     
     def testAddView(self):
 


=== Zope3/lib/python/Zope/App/ZMI/tests/testZMIViewUtility.py 1.1.2.5 => 1.1.2.6 ===
 from Zope.App.ZMI.IZMIViewService import IZMIViewService
 from Zope.ComponentArchitecture import getService, provideService
-from Zope.ComponentArchitecture import defineService, provideView, _clear
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.ComponentArchitecture import defineService, provideView
 from Zope.App.ZMI.ZMIViewUtility import ZMIViewUtility
 from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
 from Zope.App.ZopePublication.Traversers import DefaultTraverser
@@ -61,7 +62,7 @@
     __implements__ = IBrowserPublisher
 
 
-class Test(unittest.TestCase):
+class Test(CleanUp, unittest.TestCase):
 
     def setUp(self):
         defineService('ZMIViewService', IZMIViewService)
@@ -71,7 +72,7 @@
         self.oldsp = setSecurityPolicy(SecurityPolicy())
 
     def tearDown(self):
-        _clear()
+        CleanUp.tearDown(self)
         setSecurityPolicy(self.oldsp)
 
     def test(self):