summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2015-03-27 12:00:18 +0100
committerGuido Günther <agx@sigxcpu.org>2015-03-27 12:16:31 +0100
commit7ebf8438f526a51c3747907a3c93d0bfd1345b93 (patch)
tree0127a91b6eebd121eb4b91dce79f2906a98a8ff3
parent49f2da2c02effbafbbe2feff2fee76f131ca7339 (diff)
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.
-rw-r--r--tests/testutils/gbplogtester.py3
1 files changed, 2 insertions, 1 deletions
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: