[Zope-Checkins] CVS: Zope3/lib/python/Zope/Configuration/tests - Directives.py:1.1.2.3 testDirectivesXML.py:1.1.2.3 testMeta.py:1.1.2.6 testMultipleXML.py:1.1.2.2 testXML.py:1.1.2.7
Jim Fulton
jim@cvs.zope.org
Tue, 19 Feb 2002 11:05:42 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Configuration/tests
In directory cvs.zope.org:/tmp/cvs-serv7148/lib/python/Zope/Configuration/tests
Modified Files:
Tag: Zope-3x-branch
Directives.py testDirectivesXML.py testMeta.py
testMultipleXML.py testXML.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/Configuration/tests/Directives.py 1.1.2.2 => 1.1.2.3 ===
del protections[:]
del done[:]
+
+# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+from Zope.Testing.CleanUp import addCleanUp
+addCleanUp(clearDirectives)
+del addCleanUp
=== Zope3/lib/python/Zope/Configuration/tests/testDirectivesXML.py 1.1.2.2 => 1.1.2.3 ===
from cStringIO import StringIO
from Zope.Configuration.xmlconfig import xmlconfig, ZopeXMLConfigurationError
-from Zope.Configuration.tests.Directives \
- import protections, clearDirectives, done
+from Zope.Configuration.tests.Directives import protections, done
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
template = """<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
@@ -21,12 +21,7 @@
ns='http://www.zope.org/NS/Zope3/test'
-class Test(unittest.TestCase):
-
- def tearDown(self):
- from Zope.Configuration.meta import _clear
- _clear()
- clearDirectives()
+class Test(CleanUp, unittest.TestCase):
def testDirective(self):
xmlconfig(StringIO(
=== Zope3/lib/python/Zope/Configuration/tests/testMeta.py 1.1.2.5 => 1.1.2.6 ===
import unittest
from Zope.Configuration.tests.Directives \
- import protectClass, protections, doit, done, clearDirectives
+ import protectClass, protections, doit, done
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
ns='http://www.zope.org/NS/Zope3/test'
-class MetaTest(unittest.TestCase):
+class MetaTest(CleanUp, unittest.TestCase):
def testImport(self):
import Zope.Configuration.meta
-
- def tearDown(self):
- from Zope.Configuration.meta import _clear
- _clear()
- clearDirectives()
def testDirective(self):
from Zope.Configuration.meta \
=== Zope3/lib/python/Zope/Configuration/tests/testMultipleXML.py 1.1.2.1 => 1.1.2.2 ===
import unittest, sys, os
from tempfile import mktemp
-from Zope.Configuration.tests.Directives \
- import protections, clearDirectives, done
+from Zope.Configuration.tests.Directives import protections, done
from Zope.Configuration.xmlconfig import XMLConfig
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
template = """<zopeConfigure
@@ -28,12 +28,7 @@
ns='http://www.zope.org/NS/Zope3/test'
-class Test(unittest.TestCase):
-
- def tearDown(self):
- from Zope.Configuration.meta import _clear
- _clear()
- clearDirectives()
+class Test(CleanUp, unittest.TestCase):
def testNormal(self):
f2=tfile(template % ('',
=== Zope3/lib/python/Zope/Configuration/tests/testXML.py 1.1.2.6 => 1.1.2.7 ===
from cStringIO import StringIO
from Zope.Configuration.xmlconfig import xmlconfig, ZopeXMLConfigurationError
-from Zope.Configuration.tests.Directives \
- import protections, clearDirectives, done
+from Zope.Configuration.tests.Directives import protections, done
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
template = """<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
@@ -21,12 +21,7 @@
ns='http://www.zope.org/NS/Zope3/test'
-class Test(unittest.TestCase):
-
- def tearDown(self):
- from Zope.Configuration.meta import _clear
- _clear()
- clearDirectives()
+class Test(CleanUp, unittest.TestCase):
def testDirective(self):
xmlconfig(StringIO(