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)
committerJun Wang <junbill.wang@samsung.com>
Tue, 26 Jan 2016 15:31:21 +0000 (23:31 +0800)
This avoids spurious error messages during test runs.

tests/component/__init__.py

index 31911e4..baabbbd 100644 (file)
@@ -183,6 +183,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)