]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
test refactoring: clear global babel logger handlers to decrease test interdependenci...
authorFelix Schwarz <felix.schwarz@oss.schwarz.eu>
Sat, 19 Mar 2011 21:13:34 +0000 (21:13 +0000)
committerFelix Schwarz <felix.schwarz@oss.schwarz.eu>
Sat, 19 Mar 2011 21:13:34 +0000 (21:13 +0000)
babel/messages/tests/frontend.py

index 5526ca6c10d9f707f3c9c78f2120d362425ad57e..7892b75eeb22299746d5a72620c28615f01d4486 100644 (file)
@@ -513,13 +513,7 @@ class CommandLineInterfaceTestCase(unittest.TestCase):
         sys.stderr = StringIO()
         os.chdir(self.datadir)
         
-        # Logging handlers will be reused if possible (#227). This breaks the 
-        # implicit assumption that our newly created StringIO for sys.stderr 
-        # contains the console output. Removing the old handler ensures that a
-        # new handler with our new StringIO instance will be used.
-        log = logging.getLogger('babel')
-        for handler in log.handlers:
-            log.removeHandler(handler)
+        self._remove_log_handlers()
         self.cli = frontend.CommandLineInterface()
 
     def tearDown(self):
@@ -531,6 +525,16 @@ class CommandLineInterfaceTestCase(unittest.TestCase):
             locale_dir = os.path.join(self.datadir, 'project', 'i18n', dirname)
             if os.path.isdir(locale_dir):
                 shutil.rmtree(locale_dir)
+        self._remove_log_handlers()
+
+    def _remove_log_handlers(self):
+        # Logging handlers will be reused if possible (#227). This breaks the 
+        # implicit assumption that our newly created StringIO for sys.stderr 
+        # contains the console output. Removing the old handler ensures that a
+        # new handler with our new StringIO instance will be used.
+        log = logging.getLogger('babel')
+        for handler in log.handlers:
+            log.removeHandler(handler)
 
     def test_usage(self):
         try: