[bitbake-devel] [PATCH] tests/data: Add log parsing test code
Christopher Larson
clarson at kergoth.com
Tue May 26 15:26:25 UTC 2015
On Tue, May 26, 2015 at 8:17 AM, Richard Purdie <
richard.purdie at linuxfoundation.org> wrote:
> +class LogRecord():
> + def __enter__(self):
> + import logging
> + logs = []
> + class LogHandler(logging.Handler):
> + def emit(self, record):
> + logs.append(record)
> +
> + logger = logging.getLogger("BitBake")
> + handler = LogHandler()
> + logger.addHandler(handler)
> + return logs
> + def __exit__(self, type, value, traceback):
> + return
>
I realize it probably doesn’t matter in the testing case specifically, but
this lies to the user of the class. Using a context manager that doesn’t
undo what it’s done on exit.. :)
--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/bitbake-devel/attachments/20150526/ee76a190/attachment-0002.html>
More information about the bitbake-devel
mailing list