def reportUnhandledErrors(case, d):
 def cleanup():
  if isinstance(d.result, Failure):
   return d
 case.addCleanup(cleanup)
 return d

def reportUnhandledErrors ( case , d ) : def cleanup ( ) : if isinstance ( d . result , Failure ) : return d case . addCleanup ( cleanup ) return d
make sure that any unhandled errors from the given deferred are reported when the test case ends .