Author pitrou
Recipients ezio.melotti, michael.foord, pitrou, vinay.sajip
Date 2013-09-05.20:26:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1378412761.53.0.263834884699.issue18937@psf.upfronthosting.co.za>
In-reply-to
Content
It is sometimes useful to check for the log messages emitted by some piece of code (especially a library). Would it be a good idea to add a dedicated assertion method for that? I would propose the following API:


with self.assertLogging("logger.name", level="WARN") as cm:
    ...

The `cm` context manager could give access to all the log records and formatted output lines for the given logger name (and children) and at least the given logging level. I have something like that here, except not with a dedicated assertion method:
https://bitbucket.org/optiflowsrd/obelus/src/c2a2f78068123264adde8cc3ece4889c61773f00/obelus/test/__init__.py?at=default#cl-20
History
Date User Action Args
2013-09-05 20:26:01pitrousetrecipients: + pitrou, vinay.sajip, ezio.melotti, michael.foord
2013-09-05 20:26:01pitrousetmessageid: <1378412761.53.0.263834884699.issue18937@psf.upfronthosting.co.za>
2013-09-05 20:26:01pitroulinkissue18937 messages
2013-09-05 20:26:01pitroucreate