Message197022
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 |
|
Date |
User |
Action |
Args |
2013-09-05 20:26:01 | pitrou | set | recipients:
+ pitrou, vinay.sajip, ezio.melotti, michael.foord |
2013-09-05 20:26:01 | pitrou | set | messageid: <1378412761.53.0.263834884699.issue18937@psf.upfronthosting.co.za> |
2013-09-05 20:26:01 | pitrou | link | issue18937 messages |
2013-09-05 20:26:01 | pitrou | create | |
|