[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture/tests - testAPI.py:1.1.2.11 testDirectives.py:1.1.2.3 testFactory.py:1.1.2.3 testResources.py:1.1.2.3 testService.py:1.1.2.3 testSkins.py:1.1.2.8
Jim Fulton
jim@cvs.zope.org
Tue, 19 Feb 2002 11:05:41 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture/tests
In directory cvs.zope.org:/tmp/cvs-serv7148/lib/python/Zope/ComponentArchitecture/tests
Modified Files:
Tag: Zope-3x-branch
testAPI.py testDirectives.py testFactory.py testResources.py
testService.py testSkins.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/ComponentArchitecture/tests/testAPI.py 1.1.2.10 => 1.1.2.11 ===
import unittest, sys, Interface
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
class I1(Interface.Interface): pass
class I2(Interface.Interface): pass
@@ -21,11 +22,7 @@
ob = Ob()
-class Test(unittest.TestCase):
- def tearDown(self):
- # Assure a cleared registry for the next run.
- from Zope.ComponentArchitecture import _clear
- _clear()
+class Test(CleanUp, unittest.TestCase):
def testAdapter(self):
from Zope.ComponentArchitecture import getAdapter, provideAdapter
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testDirectives.py 1.1.2.2 => 1.1.2.3 ===
from Zope.ComponentArchitecture.tests.TestViews import \
IV, IC, V1, VZMI, R1, RZMI
-from Zope.ComponentArchitecture import getView, getResource, _clear
+from Zope.ComponentArchitecture import getView, getResource
from cStringIO import StringIO
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
template = """<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
@@ -28,12 +29,9 @@
class Ob:
__implements__ = IC
-class Test(unittest.TestCase):
+class Test(CleanUp, unittest.TestCase):
# XXX: tests for other directives needed
-
- def tearDown(self):
- _clear()
def testView(self):
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testFactory.py 1.1.2.2 => 1.1.2.3 ===
from Zope.ComponentArchitecture.IFactory import IFactory
from Zope.ComponentArchitecture import provideFactory, createObject
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
class MyThing:
pass
@@ -15,7 +16,7 @@
return MyThing()
-class ProvideFactoryTestCase(unittest.TestCase):
+class ProvideFactoryTestCase(CleanUp, unittest.TestCase):
def test_provide_factory(self):
provideFactory("Some.Object", MyFactory())
thing = createObject(None,"Some.Object")
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testResources.py 1.1.2.2 => 1.1.2.3 ===
from Zope.ComponentArchitecture import defineSkin, provideResource
-from Zope.ComponentArchitecture import getResource, _clear
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.ComponentArchitecture import getResource
from Zope.ComponentArchitecture import getRequestResource
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
from Interface import Interface
from Request import Request
-class Test(unittest.TestCase):
-
- def tearDown(self):
- _clear()
+class Test(CleanUp, unittest.TestCase):
def testSkin(self):
class I2(Interface): pass
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testService.py 1.1.2.2 => 1.1.2.3 ===
from Zope.ComponentArchitecture import defineService, provideService
-from Zope.ComponentArchitecture import getService, _clear
+from Zope.ComponentArchitecture import getService
from Zope.ComponentArchitecture.Service import UndefinedService, InvalidService
from Zope.Exceptions import DuplicationError
from Interface import Interface
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
import unittest, sys
@@ -35,10 +36,7 @@
class ServiceTwo:
pass
-class Test(unittest.TestCase):
-
- def tearDown(self):
- _clear()
+class Test(CleanUp, unittest.TestCase):
def testNormal(self):
defineService('one', IOne)
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testSkins.py 1.1.2.7 => 1.1.2.8 ===
import unittest, sys
-from Zope.ComponentArchitecture import defineSkin, provideView, getView, _clear
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.ComponentArchitecture import defineSkin, provideView, getView
from Zope.ComponentArchitecture import getRequestView
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
from Interface import Interface
from Request import Request
-class Test(unittest.TestCase):
-
- def tearDown(self):
- _clear()
+class Test(CleanUp, unittest.TestCase):
def testSkin(self):
class I1(Interface): pass