def tbot_end(success: bool) -> None: log.message( log.c( log.u( "────────────────────────────────────────", "----------------------------------------", )).dark) if log.LOGFILE is not None: log.message(f"Log written to {log.LOGFILE.name!r}") msg = log.c("SUCCESS").green.bold if success else log.c("FAILURE").red.bold duration = time.monotonic() - log.START_TIME log.EventIO( ["tbot", "end"], msg + f" ({duration:.3f}s)", nest_first=log.u("└─", "\\-"), verbosity=log.Verbosity.QUIET, success=success, duration=duration, )
def testcase_end(name: str, duration: float, success: bool = True) -> None: """ Log a testcase's end. :param float duration: Time passed while this testcase ran :param bool success: Whether the testcase succeeded """ if success: success_string = c("Done").green.bold else: success_string = c("Fail").red.bold log.EventIO( ["tc", "end"], success_string + f". ({duration:.3f}s)", nest_first=u("└─", "\\-"), verbosity=log.Verbosity.QUIET, name=name, duration=duration, success=success, ) log.NESTING -= 1
def testcase_end( name: str, duration: float, success: bool = True, skipped: typing.Optional[str] = None, ) -> None: """ Log a testcase's end. :param float duration: Time passed while this testcase ran :param bool success: Whether the testcase succeeded :param str skipped: ``None`` if the testcase ran normally or a string (the reason) if it was skipped. If a testcase was skipped, ``success`` is ignored. """ if skipped is not None: message = c("Skipped").yellow.bold + f": {skipped}" skip_info = {"skip_reason": skipped} else: # Testcase ran normally skip_info = {} if success: message = c("Done").green.bold + f". ({duration:.3f}s)" else: message = c("Fail").red.bold + f". ({duration:.3f}s)" log.EventIO( ["tc", "end"], message, nest_first=u("└─", "\\-"), verbosity=log.Verbosity.QUIET, name=name, duration=duration, success=success, skipped=skipped is not None, **skip_info, ) log.NESTING -= 1