Skip to content

template_util

Helper classes and function for the Jinja template.

TemplateUtil

TemplateUtil(output_dir: str)

Helper class for the Jinja template.

Parameters:

  • output_dir (str) –

    The original output directory of the Robot tests

Source code in src/robot_markdown/template_util.py
 9
10
11
12
13
14
15
def __init__(self, output_dir: str) -> None:
    """Creates a new util instance.

    Parameters:
        output_dir: The original output directory of the Robot tests
    """
    self.output_dir = output_dir

get_log_messages

get_log_messages(kw: Keyword | TestCase) -> list[Message]

Returns all log messages of a keyword or a test case and all its children.

Parameters:

  • kw (Keyword | TestCase) –

    Either a Keyword or a Testcase

Retunrs

List of messages

Source code in src/robot_markdown/template_util.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def get_log_messages(self, kw: Keyword | TestCase) -> list[Message]:
    """Returns all log messages of a keyword or a test case and all its children.

    Parameters:
        kw: Either a Keyword or a Testcase

    Retunrs:
        List of messages
    """
    if hasattr(kw, "type") and kw.type == Keyword.MESSAGE:
        if kw.html:
            kw.message = kw.message.replace(f"file://{self.output_dir}", "")
        return [kw]
    if not hasattr(kw, "body"):
        return []

    messages: list[Message] = []
    for item in kw.body:
        messages.extend(self.get_log_messages(item))

    return messages