[bitbake-devel] [PATCH] tests/data: Add log parsing test code

Richard Purdie richard.purdie at linuxfoundation.org
Wed May 27 16:34:15 UTC 2015


On Tue, 2015-05-26 at 08:26 -0700, Christopher Larson wrote:
> 
> 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.. :)

Er, yes, quite. I knew there was something I'd meant to go back and do
once it worked. I've posted a v2 with that fixed.

Cheers,

Richard





More information about the bitbake-devel mailing list