示例#1
0
def format_test(msg, last_test_id, keyword):
    flags = Flags(msg["test_flags"])
    if flags & SKIP and settings.show_skipped is False:
        return

    if getattr(TestType, msg["test_type"]) < TestType.Iteration:
        return

    icon = '\u27A4 '

    keyword += format_type(msg)

    _keyword = color_keyword(keyword)
    _name = color_test_name(split(msg["test_name"])[-1])
    _indent = indent * (msg["test_id"].count('/') - 1)
    out = f"{_indent}{icon}{_keyword} {_name}\n"

    last_test_id.append(msg["test_id"])

    return out
示例#2
0
def format_test(msg, last_test_id, keyword):
    flags = Flags(msg.p_flags)
    if flags & SKIP and settings.show_skipped is False:
        return

    if msg.p_type < TestType.Test:
        return

    icon = '\u27A4 '

    keyword += format_type(msg)

    _keyword = color_keyword(keyword)
    _name = color_test_name(split(msg.name)[-1])
    _indent = indent * (msg.p_id.count('/') - 1)
    out = f"{_indent}{icon}{_keyword} {_name}\n"

    if last_test_id:
        last_test_id.pop()
    last_test_id.append(msg.p_id)

    return out
示例#3
0
def color_test_name(name):
    return color(split(name)[-1], "white", attrs=[])
示例#4
0
def color_secondary_keyword(keyword):
    return color(split(keyword)[-1], "white", attrs=["bold", "dim"])
示例#5
0
def color_keyword(keyword):
    return color(split(keyword)[-1], "white", attrs=["dim"])
示例#6
0
def format_test(msg, keyword):
    flags = Flags(msg.p_flags)
    if flags & SKIP and settings.show_skipped is False:
        return

    # add test to the tests map
    parent = parentname(msg.p_id)
    if tests_by_parent.get(parent) is None:
        tests_by_parent[parent] = []
    tests_by_parent[parent].append(msg)
    tests_by_name[msg.p_id] = msg

    if msg.p_type == TestType.Module:
        keyword += "Module"
    elif msg.p_type == TestType.Suite:
        if msg.p_subtype == TestSubType.Feature:
            keyword += "Feature"
        else:
            keyword += "Suite"
    elif msg.p_type == TestType.Iteration:
        keyword += "Iteration"
    elif msg.p_type == TestType.Step:
        if msg.p_subtype == TestSubType.And:
            keyword += "And"
        elif msg.p_subtype == TestSubType.Given:
            keyword += and_keyword(msg, parent, "Given", TestSubType.Given)
        elif msg.p_subtype == TestSubType.When:
            keyword += and_keyword(msg, parent, "When", TestSubType.When)
        elif msg.p_subtype == TestSubType.Then:
            keyword += and_keyword(msg, parent, "Then", TestSubType.Then)
        elif msg.p_subtype == TestSubType.By:
            keyword += and_keyword(msg, parent, "By", TestSubType.By)
        elif msg.p_subtype == TestSubType.But:
            keyword += and_keyword(msg, parent, "But", TestSubType.But)
        elif msg.p_subtype == TestSubType.Finally:
            keyword += and_keyword(msg, parent, "Finally", TestSubType.Finally)
        else:
            keyword += "Step"
    else:
        if msg.p_subtype == TestSubType.Scenario:
            keyword += "Scenario"
        elif msg.p_subtype == TestSubType.Background:
            keyword += "Background"
        else:
            keyword += "Test"

    started = strftime(localfromtimestamp(msg.started))
    _keyword = color_keyword(keyword)
    _name = color_other(split(msg.name)[-1])
    _indent = f"{started:>20}" + f"{'':3}{indent * (msg.p_id.count('/') - 1)}"
    out = f"{color_other(_indent)}{_keyword} {_name}{color_other(', flags:' + str(flags) if flags else '')}\n"
    # convert indent to just spaces
    _indent = (len(_indent) + 3) * " "
    if msg.description:
        out += format_description(msg, _indent)
    if msg.tags:
        out += format_tags(msg, _indent)
    if msg.requirements:
        out += format_requirements(msg, _indent)
    if msg.attributes:
        out += format_attributes(msg, _indent)
    if msg.users:
        out += format_users(msg, _indent)
    if msg.tickets:
        out += format_tickets(msg, _indent)
    if msg.args:
        out += format_arguments(msg, _indent)
    if msg.examples:
        out += format_examples(msg, _indent)
    return out
示例#7
0
def color_test_name(name, no_colors=False):
    return color(split(name)[-1], "white", attrs=[], no_colors=no_colors)
示例#8
0
def color_secondary_keyword(keyword, no_colors=False):
    return color(split(keyword)[-1],
                 "white",
                 attrs=["bold", "dim"],
                 no_colors=no_colors)
示例#9
0
def color_keyword(keyword, no_colors=False):
    return color(split(keyword)[-1],
                 "white",
                 attrs=["bold"],
                 no_colors=no_colors)
示例#10
0
def format_test(msg, keyword, tests_by_parent, tests_by_id, no_colors=False):
    # add test to the tests map
    parent = parentname(msg["test_id"])
    if tests_by_parent.get(parent) is None:
        tests_by_parent[parent] = []
    tests_by_parent[parent].append(msg)
    tests_by_id[msg["test_id"]] = msg

    test_type = get_type(msg)
    test_subtype = get_subtype(msg)

    if test_subtype == TestSubType.Example:
        keyword += "Example"
    elif test_type == TestType.Module:
        keyword += "MODULE"
    elif test_type == TestType.Suite:
        if test_subtype == TestSubType.Feature:
            keyword += "FEATURE"
        else:
            keyword += "SUITE"
    elif test_type == TestType.Iteration:
        keyword += "Iteration"
    elif test_type == TestType.Step:
        if test_subtype == TestSubType.And:
            keyword += "\u25a1 And"
        elif test_subtype == TestSubType.Given:
            keyword += and_keyword(msg, parent, "\u25a1 Given",
                                   TestSubType.Given)
        elif test_subtype == TestSubType.When:
            keyword += and_keyword(msg, parent, "\u25a1 When",
                                   TestSubType.When)
        elif test_subtype == TestSubType.Then:
            keyword += and_keyword(msg, parent, "\u25a1 Then",
                                   TestSubType.Then)
        elif test_subtype == TestSubType.By:
            keyword += and_keyword(msg, parent, "\u25a1 By", TestSubType.By)
        elif test_subtype == TestSubType.But:
            keyword += and_keyword(msg, parent, "\u25a1 But", TestSubType.But)
        elif test_subtype == TestSubType.Finally:
            keyword += and_keyword(msg, parent, "\u25a1 Finally",
                                   TestSubType.Finally)
        elif test_subtype == TestSubType.Background:
            keyword += and_keyword(msg, parent, "\u25a1 Background",
                                   TestSubType.Background)
        else:
            keyword += "\u25a1 Step"
    elif test_type == TestType.Outline:
        keyword += "OUTLINE"
    else:
        if test_subtype == TestSubType.Scenario:
            keyword += "SCENARIO"
        elif test_subtype == TestSubType.Check:
            keyword += "CHECK"
        elif test_subtype == TestSubType.Recipe:
            keyword += "RECIPE"
        else:
            keyword += "TEST"

    _keyword = color_keyword(keyword, no_colors=no_colors)
    _name = color_test_name(split(msg["test_name"])[-1], no_colors=no_colors)

    out = ""

    if test_type > TestType.Step:
        out += clear_screen()

    if test_type > TestType.Step:
        out += f"{separators[test_type]}"

    out += f"{_keyword} {_name}\n"
    if msg["test_description"]:
        out += format_test_description(msg, "", no_colors=no_colors)

    if test_type > TestType.Step:
        out += f"{separators[test_type]}"

    return out
示例#11
0
def format_test(msg, keyword):
    # add test to the tests map
    parent = parentname(msg["test_id"])
    if tests_by_parent.get(parent) is None:
        tests_by_parent[parent] = []
    tests_by_parent[parent].append(msg)
    tests_by_name[msg["test_id"]] = msg

    flags = Flags(msg["test_flags"])
    test_type = get_type(msg)
    test_subtype = get_subtype(msg)

    if test_subtype == TestSubType.Example:
        keyword += "Example"
    elif test_type == TestType.Module:
        keyword += "Module"
    elif test_type == TestType.Suite:
        if test_subtype == TestSubType.Feature:
            keyword += "Feature"
        else:
            keyword += "Suite"
    elif test_type == TestType.Iteration:
        keyword += "Iteration"
    elif test_type == TestType.Step:
        if test_subtype == TestSubType.And:
            keyword += "And"
        elif test_subtype == TestSubType.Given:
            keyword += and_keyword(msg, parent, "Given", TestSubType.Given)
        elif test_subtype == TestSubType.When:
            keyword += and_keyword(msg, parent, "When", TestSubType.When)
        elif test_subtype == TestSubType.Then:
            keyword += and_keyword(msg, parent, "Then", TestSubType.Then)
        elif test_subtype == TestSubType.By:
            keyword += and_keyword(msg, parent, "By", TestSubType.By)
        elif test_subtype == TestSubType.But:
            keyword += and_keyword(msg, parent, "But", TestSubType.But)
        elif test_subtype == TestSubType.Finally:
            keyword += and_keyword(msg, parent, "Finally", TestSubType.Finally)
        elif test_subtype == TestSubType.Background:
            keyword += and_keyword(msg, parent, "Background",
                                   TestSubType.Background)
        else:
            keyword += "Step"
    elif test_type == TestType.Outline:
        keyword += "Outline"
    else:
        if test_subtype == TestSubType.Scenario:
            keyword += "Scenario"
        elif test_subtype == TestSubType.Check:
            keyword += "Check"
        elif test_subtype == TestSubType.Recipe:
            keyword += "Recipe"
        else:
            keyword += "Test"

    started = strftime(localfromtimestamp(msg["message_time"]))
    _keyword = color_keyword(keyword)
    _name = color_other(split(msg["test_name"])[-1])
    _indent = f"{started:>20}" + f"{'':3}{indent * (msg['test_id'].count('/') - 1)}"
    out = f"{color_other(_indent)}{_keyword} {_name}{color_other(', flags:' + str(flags) if flags else '')}\n"
    # convert indent to just spaces
    _indent = (len(_indent) + 3) * " "
    if msg["test_description"]:
        out += format_test_description(msg, _indent)
    return out
示例#12
0
def format_test(msg, keyword, tests_by_parent, tests_by_id, no_colors=False):
    # add test to the tests map
    parent = parentname(msg["test_id"])
    if tests_by_parent.get(parent) is None:
        tests_by_parent[parent] = []
    tests_by_parent[parent].append(msg)
    tests_by_id[msg["test_id"]] = msg

    test_type = get_type(msg)
    test_subtype = get_subtype(msg)

    if test_subtype == TestSubType.Example:
        keyword += "Example"
    elif test_type == TestType.Module:
        keyword += "Module"
    elif test_type == TestType.Suite:
        if test_subtype == TestSubType.Feature:
            keyword += "Feature"
        else:
            keyword += "Suite"
    elif test_type == TestType.Iteration:
        keyword += "Iteration"
    elif test_type == TestType.Step:
        if test_subtype == TestSubType.And:
            keyword += "And"
        elif test_subtype == TestSubType.Given:
            keyword += and_keyword(msg, parent, "Given", TestSubType.Given)
        elif test_subtype == TestSubType.When:
            keyword += and_keyword(msg, parent, "When", TestSubType.When)
        elif test_subtype == TestSubType.Then:
            keyword += and_keyword(msg, parent, "Then", TestSubType.Then)
        elif test_subtype == TestSubType.By:
            keyword += and_keyword(msg, parent, "By", TestSubType.By)
        elif test_subtype == TestSubType.But:
            keyword += and_keyword(msg, parent, "But", TestSubType.But)
        elif test_subtype == TestSubType.Finally:
            keyword += and_keyword(msg, parent, "Finally", TestSubType.Finally)
        elif test_subtype == TestSubType.Background:
            keyword += and_keyword(msg, parent, "Background",
                                   TestSubType.Background)
        else:
            keyword += "Step"
    elif test_type == TestType.Outline:
        keyword += "Outline"
    else:
        if test_subtype == TestSubType.Scenario:
            keyword += "Scenario"
        elif test_subtype == TestSubType.Check:
            keyword += "Check"
        elif test_subtype == TestSubType.Recipe:
            keyword += "Recipe"
        else:
            keyword += "Test"

    _keyword = color_keyword(keyword, no_colors=no_colors)
    _name = color_test_name(split(msg["test_name"])[-1], no_colors=no_colors)
    _indent = indent * (msg["test_id"].count('/') - 1)
    out = f"{_indent}{_keyword} {_name}\n"
    if msg["test_description"]:
        out += format_test_description(msg, _indent, no_colors=no_colors)
    return out
示例#13
0
def format_test(msg, keyword, tests_by_parent, tests_by_id):
    flags = Flags(msg.p_flags)
    if flags & SKIP and settings.show_skipped is False:
        return

    # add test to the tests map
    parent = parentname(msg.p_id)
    if tests_by_parent.get(parent) is None:
        tests_by_parent[parent] = []
    tests_by_parent[parent].append(msg)
    tests_by_id[msg.p_id] = msg

    if msg.p_type == TestType.Module:
        keyword += "Module"
    elif msg.p_type == TestType.Suite:
        if msg.p_subtype == TestSubType.Feature:
            keyword += "Feature"
        else:
            keyword += "Suite"
    elif msg.p_type == TestType.Iteration:
        keyword += "Iteration"
    elif msg.p_type == TestType.Step:
        if msg.p_subtype == TestSubType.And:
            keyword += "And"
        elif msg.p_subtype == TestSubType.Given:
            keyword += and_keyword(msg, parent, "Given", TestSubType.Given)
        elif msg.p_subtype == TestSubType.When:
            keyword += and_keyword(msg, parent, "When", TestSubType.When)
        elif msg.p_subtype == TestSubType.Then:
            keyword += and_keyword(msg, parent, "Then", TestSubType.Then)
        elif msg.p_subtype == TestSubType.By:
            keyword += and_keyword(msg, parent, "By", TestSubType.By)
        elif msg.p_subtype == TestSubType.But:
            keyword += and_keyword(msg, parent, "But", TestSubType.But)
        elif msg.p_subtype == TestSubType.Finally:
            keyword += and_keyword(msg, parent, "Finally", TestSubType.Finally)
        else:
            keyword += "Step"
    else:
        if msg.p_subtype == TestSubType.Scenario:
            keyword += "Scenario"
        elif msg.p_subtype == TestSubType.Background:
            keyword += "Background"
        else:
            keyword += "Test"

    _keyword = color_keyword(keyword)
    _name = color_test_name(split(msg.name)[-1])
    _indent = indent * (msg.p_id.count('/') - 1)
    out = f"{_indent}{_keyword} {_name}\n"
    if msg.description:
        out += format_description(msg, _indent)
    if msg.tags:
        out += format_tags(msg, _indent)
    if msg.requirements:
        out += format_requirements(msg, _indent)
    if msg.attributes:
        out += format_attributes(msg, _indent)
    if msg.users:
        out += format_users(msg, _indent)
    if msg.tickets:
        out += format_tickets(msg, _indent)
    if msg.args:
        out += format_arguments(msg, _indent)
    if msg.examples:
        out += format_examples(msg, _indent)
    return out