From 7ebf8438f526a51c3747907a3c93d0bfd1345b93 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 27 Mar 2015 12:00:18 +0100 Subject: gbplogtester: Reliably remove all handlers So far we were modifying the list of handlers in place which resulted in all handlers being removed at the second call to _capture_log only. --- tests/testutils/gbplogtester.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testutils/gbplogtester.py b/tests/testutils/gbplogtester.py index 77d4135..0c95199 100644 --- a/tests/testutils/gbplogtester.py +++ b/tests/testutils/gbplogtester.py @@ -23,7 +23,8 @@ class GbpLogTester(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: + handlers = list(gbp.log.LOGGER.handlers) + for hdl in handlers: gbp.log.LOGGER.removeHandler(hdl) gbp.log.LOGGER.addHandler(self._loghandler) else: -- cgit v1.2.3