from typing import Callable
import logging


def _test_unit_wrapper(test_func: Callable[[], bool]) -> Callable[[], int]:
  """Wraps a test function with post processing functionality.

  In particular, the test_func wrapper invokes test_func, logs the test and its
  status, and returns a value to indicate the number of failing tests.

  Args:
    test_func: A Callable object for invoking the test. It returns a boolean
      boolean to indicate the test status of passing (True) or failing (False).

  Returns:
    A wrapper of the test_func.
  """

  def wrapper() -> int:
    passed = test_func()

    status_str = "passed" if passed else "failed"
    logging.info(f"{test_func.__name__} {status_str}.")

    return int(passed == False)

  return wrapper