[Zodb-checkins] CVS: ZODB3/zLOG/tests - testzLogConfig.py:1.10

Fred L. Drake, Jr. fred@zope.com
Thu, 23 Jan 2003 16:18:09 -0500


Update of /cvs-repository/ZODB3/zLOG/tests
In directory cvs.zope.org:/tmp/cvs-serv26620

Modified Files:
	testzLogConfig.py 
Log Message:
Attempt to save/restore the state of the logging configuration around
the tests.


=== ZODB3/zLOG/tests/testzLogConfig.py 1.9 => 1.10 ===
--- ZODB3/zLOG/tests/testzLogConfig.py:1.9	Thu Jan 23 15:17:22 2003
+++ ZODB3/zLOG/tests/testzLogConfig.py	Thu Jan 23 16:18:05 2003
@@ -28,6 +28,22 @@
 
 class TestzLOGConfig(unittest.TestCase):
 
+    # XXX This tries to save and restore the state of logging around
+    # the test.  Somewhat surgical; there may be a better way.
+
+    def setUp(self):
+        self._old_logger = logging.getLogger("event")
+        self._old_level = self._old_logger.level
+        self._old_handlers = self._old_logger.handlers[:]
+        self._old_logger.handlers[:] = [zLOG.LogHandlers.NullHandler()]
+
+    def tearDown(self):
+        for h in self._old_logger.handlers:
+            self._old_logger.removeHandler(h)
+        for h in self._old_handlers:
+            self._old_logger.addHandler(h)
+        self._old_logger.setLevel(self._old_level)
+
     _schema = None
     _schematext = """
       <schema>