Remove all other log handlers when capturing logs
authorGuido Günther <agx@sigxcpu.org>
Mon, 28 Jul 2014 13:57:05 +0000 (15:57 +0200)
committerGuido Günther <agx@sigxcpu.org>
Mon, 28 Jul 2014 13:57:05 +0000 (15:57 +0200)
This avoids spurious error messages during test runs.

tests/component/__init__.py

index 4ef2256..7abb16d 100644 (file)
@@ -153,6 +153,8 @@ class ComponentTestBase(object):
             self._loghandler = gbp.log.GbpStreamHandler(self._log, False)
             self._loghandler.addFilter(gbp.log.GbpFilter([gbp.log.WARNING,
                                                           gbp.log.ERROR]))
+            for hdl in gbp.log.LOGGER.handlers:
+                gbp.log.LOGGER.removeHandler(hdl)
             gbp.log.LOGGER.addHandler(self._loghandler)
         elif self._log is not None:
             gbp.log.LOGGER.removeHandler(self._loghandler)