def _format_bootstrap_report(result):
  """Formats a `_BootstrapResult` as a complete report str.

  The information presented includes:
  - The results of a bootstrap to test how often the test fails
  - A confidence interval on the probability of the
    `assertAllMeansClose` failing, assuming the empirical distribution
    is close to the true distribution

  This differs conceptually from the `_gaussian_report` because it
  doesn't assume that the distribution on means Gaussianizes, so
  remains valid in a low-sample setting.  On the other hand, when
  trustworthy, `_gaussian_report` is more informative.

  Args:
    result: A `_BootstrapResult` capturing the fit.

  Returns:
    report: A Python  `str` suitable for being printed or added to an
      assertion message.

  """
  report = (
      f'\n{result.failures} of {result.trials} bootstrapped trials fail.'
      '\nAssuming that the empirical distribution is the true distribution:')
  for rate in [1e-3, 1e-9]:
    one_rate = result.for_error_rate(rate)
    report += (
        f'\n- With confidence 1 - {rate}, p(fail) >= {one_rate.low_p:.3g}.'
        f'\n- With confidence 1 - {rate}, p(fail) <= {one_rate.high_p:.3g}.')
  return report