def assertLogMessage(testCase, expectedMessages, callable, *args, **kwargs):
 loggedMessages = []
 log.addObserver(loggedMessages.append)
 testCase.addCleanup(log.removeObserver, loggedMessages.append)
 callable(*args, **kwargs)
 testCase.assertEqual([m['message'][0] for m in loggedMessages], expectedMessages)

def assertLogMessage ( testCase , expectedMessages , callable , * args , ** kwargs ) : loggedMessages = [ ] log . addObserver ( loggedMessages . append ) testCase . addCleanup ( log . removeObserver , loggedMessages . append ) callable ( * args , ** kwargs ) testCase . assertEqual ( [ m [ 'message' ] [ 0 ] for m in loggedMessages ] , expectedMessages )
assert that the callable logs the expected messages when called .