From 49f2da2c02effbafbbe2feff2fee76f131ca7339 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 27 Mar 2015 11:52:04 +0100 Subject: gbplogtester: Make sure log capture start is followed by a log capture stop --- tests/testutils/gbplogtester.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/testutils/gbplogtester.py b/tests/testutils/gbplogtester.py index 9a54f02..77d4135 100644 --- a/tests/testutils/gbplogtester.py +++ b/tests/testutils/gbplogtester.py @@ -17,7 +17,8 @@ class GbpLogTester(object): def _capture_log(self, capture=True): """ Capture log""" - if capture and self._log is None: + if capture: + assert self._log is None, "Log capture already started" self._log = StringIO() self._loghandler = gbp.log.GbpStreamHandler(self._log, False) self._loghandler.addFilter(gbp.log.GbpFilter([gbp.log.WARNING, @@ -25,7 +26,8 @@ class GbpLogTester(object): for hdl in gbp.log.LOGGER.handlers: gbp.log.LOGGER.removeHandler(hdl) gbp.log.LOGGER.addHandler(self._loghandler) - elif self._log is not None: + else: + assert self._log is not None, "Log capture not started" gbp.log.LOGGER.removeHandler(self._loghandler) self._loghandler.close() self._loghandler = None -- cgit v1.2.3