def test_doesnt_call_hook_when_removed(self): # remove_exception_logging_hook removes the hook function, ensuring # it's not called when Bazaar logs an exception. exceptions = [] def hook(): exceptions.append(sys.exc_info()[:2]) add_exception_logging_hook(hook) remove_exception_logging_hook(hook) self.logException(RuntimeError('foo')) self.assertEqual([], exceptions)
def test_doesnt_call_hook_when_removed(self): # remove_exception_logging_hook removes the hook function, ensuring # it's not called when Bazaar logs an exception. exceptions = [] def hook(): exceptions.append(sys.exc_info()[:2]) add_exception_logging_hook(hook) remove_exception_logging_hook(hook) self.logException(RuntimeError('foo')) self.assertEqual([], exceptions)
def test_calls_hook_when_added(self): # add_exception_logging_hook adds a hook function that's called # whenever Bazaar logs an exception. exceptions = [] def hook(): exceptions.append(sys.exc_info()[:2]) add_exception_logging_hook(hook) self.addCleanup(remove_exception_logging_hook, hook) exception = RuntimeError('foo') self.logException(exception) self.assertEqual([(RuntimeError, exception)], exceptions)
def test_calls_hook_when_added(self): # add_exception_logging_hook adds a hook function that's called # whenever Bazaar logs an exception. exceptions = [] def hook(): exceptions.append(sys.exc_info()[:2]) add_exception_logging_hook(hook) self.addCleanup(remove_exception_logging_hook, hook) exception = RuntimeError('foo') self.logException(exception) self.assertEqual([(RuntimeError, exception)], exceptions)