diff options
author | Guido Günther <agx@sigxcpu.org> | 2015-03-27 11:52:04 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2015-03-27 12:16:31 +0100 |
commit | 49f2da2c02effbafbbe2feff2fee76f131ca7339 (patch) | |
tree | 9490db6e9c5f21cd88a980fc702537737a3201d7 /tests/testutils/gbplogtester.py | |
parent | 0b98c48cbe28a01e325d4877ab76395db6548461 (diff) |
gbplogtester: Make sure log capture start is followed by a log capture stop
Diffstat (limited to 'tests/testutils/gbplogtester.py')
-rw-r--r-- | tests/testutils/gbplogtester.py | 6 |
1 files 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 |