Exemplo n.º 1
0
 def _print_traceback(self, fail_reason):
     print(colorful.bold_red(fail_reason.get_name())
             + colorful.red(" exception caught from external hook at ")
             + colorful.bold_red(fail_reason.get_filename())
             + colorful.red(":")
             + colorful.bold_red(str(fail_reason.get_line_no())))
     if Config().with_traceback:
         for l in fail_reason.get_traceback().splitlines():
             colorful.out.red("  " + l)
     else:
         print("  " + colorful.red(fail_reason.get_name() + ": ") + colorful.bold_red(fail_reason.get_reason()))
     sys.stdout.write("\n")
Exemplo n.º 2
0
def print_after_step(step):
    if not step.is_dry_run():
        splitted = step.get_sentence_splitted()
        if not Config().no_line_jump and not Config().no_overwrite:
            sys.stdout.write("\033[A\033[K" * splitted[0])

        if step.has_passed() is None and Config().no_skipped_steps:
            return

        if step.has_passed():
            color_fn = colorful.bold_green
        elif step.has_passed() is False:
            color_fn = colorful.bold_red
        elif step.has_passed() is None:
            color_fn = colorful.cyan

        if not Config().no_overwrite:
            if not Config().no_indentation:
                sys.stdout.write(step.get_indentation())
            if not Config().no_numbers:
                sys.stdout.write(color_fn("%*d. " % (0 if Config().no_indentation else len(str(Config().highest_step_id)), step.get_id())))
            sys.stdout.write(color_fn(splitted[1]))
            sys.stdout.write("\n")

        if step.has_passed() is False:
            if Config().with_traceback:
                for l in step.get_fail_reason().get_traceback().splitlines():
                    if not Config().no_indentation:
                        sys.stdout.write(step.get_sentence_indentation())
                    colorful.out.red(l)
            else:
                if not Config().no_indentation:
                    sys.stdout.write(step.get_sentence_indentation())
                print(colorful.red(step.get_fail_reason().get_name() + ": ") + colorful.bold_red(step.get_fail_reason().get_reason()))
        sys.stdout.flush()