[Zconfig] SVN: ZConfig/trunk/components/logger/tests/test_logger.py - move some helper methods to a base class

Fred L. Drake, Jr. fred at zope.com
Fri Jul 23 19:10:14 EDT 2004


Log message for revision 26739:
  - move some helper methods to a base class
  - allow a test determine which logger is saved/restored by the base class
    harness
  


Changed:
  U   ZConfig/trunk/components/logger/tests/test_logger.py


-=-
Modified: ZConfig/trunk/components/logger/tests/test_logger.py
===================================================================
--- ZConfig/trunk/components/logger/tests/test_logger.py	2004-07-23 22:12:52 UTC (rev 26738)
+++ ZConfig/trunk/components/logger/tests/test_logger.py	2004-07-23 23:10:13 UTC (rev 26739)
@@ -32,8 +32,10 @@
     # XXX This tries to save and restore the state of logging around
     # the test.  Somewhat surgical; there may be a better way.
 
+    name = None
+
     def setUp(self):
-        self._old_logger = logging.getLogger()
+        self._old_logger = logging.getLogger(self.name)
         self._old_level = self._old_logger.level
         self._old_handlers = self._old_logger.handlers[:]
         self._old_logger.handlers[:] = []
@@ -46,16 +48,7 @@
             self._old_logger.addHandler(h)
         self._old_logger.setLevel(self._old_level)
 
-
-class TestConfig(LoggingTestBase):
-
     _schema = None
-    _schematext = """
-      <schema>
-        <import package='ZConfig.components.logger'/>
-        <section type='eventlog' name='*' attribute='eventlog'/>
-      </schema>
-    """
 
     def get_schema(self):
         if self._schema is None:
@@ -69,6 +62,16 @@
         self.assert_(not handler)
         return conf
 
+
+class TestConfig(LoggingTestBase):
+
+    _schematext = """
+      <schema>
+        <import package='ZConfig.components.logger'/>
+        <section type='eventlog' name='*' attribute='eventlog'/>
+      </schema>
+    """
+
     def test_logging_level(self):
         # Make sure the expected names are supported; it's not clear
         # how to check the values in a meaningful way.



More information about the ZConfig mailing list