def ExtractTestOutputAndCleanup(test):
  """Test output is in temp files. Read those and delete them.
  Returns: A tuple (stderr, stdout).
  """
  outputs = [None, None]
  for i, stream_name in ((0, "stdout"), (1, "stderr")):
    stream = test[stream_name]
    stream.seek(0)
    outputs[i] = stream.read()
    stream.close()

  return outputs