robot.result package

Implements parsing execution results from XML output files.

The main public API of this package consists of the ExecutionResult() factory method, that returns Result objects, and of the ResultVisitor abstract class, that eases further processing the results.

The model objects in the model module can also be considered to be part of the public API, because they can be found inside the Result object. They can also be inspected and modified as part of the normal test execution by pre-Rebot modifiers and listeners.

It is highly recommended to import the public entry-points via the robot.api package like in the example below. In those rare cases where the aforementioned model objects are needed directly, they can be imported from this package.

This package is considered stable.

Example

#!/usr/bin/env python

"""Usage: check_test_times.py seconds inpath [outpath]

Reads test execution result from an output XML file and checks that no test
took longer than given amount of seconds to execute.

Optional `outpath` specifies where to write processed results. If not given,
results are written over the original file.
"""

import sys
from robot.api import ExecutionResult, ResultVisitor


class ExecutionTimeChecker(ResultVisitor):

    def __init__(self, max_seconds):
        self.max_milliseconds = max_seconds * 1000

    def visit_test(self, test):
        if test.status == 'PASS' and test.elapsedtime > self.max_milliseconds:
            test.status = 'FAIL'
            test.message = 'Test execution took too long.'


def check_tests(seconds, inpath, outpath=None):
    result = ExecutionResult(inpath)
    result.visit(ExecutionTimeChecker(float(seconds)))
    result.save(outpath)


if __name__ == '__main__':
    try:
        check_tests(*sys.argv[1:])
    except TypeError:
        print __doc__

Submodules

robot.result.configurer module

class robot.result.configurer.SuiteConfigurer(remove_keywords=None, log_level=None, start_time=None, end_time=None, critical_tags=None, non_critical_tags=None, **base_config)[source]

Bases: robot.model.configurer.SuiteConfigurer

Result suite configured.

Calls suite’s remove_keywords(), filter_messages() and set_criticality() methods and sets its start and end time based on the given named parameters.

base_config is forwarded to robot.model.SuiteConfigurer that will do further configuration based on them.

visit_suite(suite)[source]
add_tags
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_suite(suite)

Called when suite ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

remove_tags
start_keyword(keyword)

Called when keyword starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_suite(suite)

Called when suite starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_keyword(kw)

Implements traversing through the keyword and its child keywords.

Can be overridden to allow modifying the passed in kw without calling start_keyword() or end_keyword() nor visiting child keywords.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_test(test)

Implements traversing through the test and its keywords.

Can be overridden to allow modifying the passed in test without calling start_test() or end_test() nor visiting keywords.

robot.result.executionerrors module

class robot.result.executionerrors.ExecutionErrors(messages=None)[source]

Bases: object

Represents errors occurred during the execution of tests.

An error might be, for example, that importing a library has failed.

message_class

alias of Message

messages

A list-like object of Message instances.

add(other)[source]
visit(visitor)[source]

robot.result.executionresult module

class robot.result.executionresult.Result(source=None, root_suite=None, errors=None)[source]

Bases: object

Test execution results.

Can be created based on XML output files using the ExecutionResult() factory method. Also returned by the robot.running.TestSuite.run method.

source = None

Path to the XML file where results are read from.

suite = None

Hierarchical execution results as a TestSuite object.

errors = None

Execution errors as an ExecutionErrors object.

statistics

Test execution statistics.

Statistics are an instance of Statistics that is created based on the contained suite and possible configuration.

Statistics are created every time this property is accessed. Saving them to a variable is thus often a good idea to avoid re-creating them unnecessarily:

from robot.api import ExecutionResult

result = ExecutionResult('output.xml')
result.configure(stat_config={'suite_stat_level': 2,
                              'tag_stat_combine': 'tagANDanother'})
stats = result.statistics
print stats.total.critical.failed
print stats.total.critical.passed
print stats.tags.combined[0].total
return_code

Return code (integer) of test execution.

By default returns the number of failed critical tests (max 250), but can be configured to always return 0.

configure(status_rc=True, suite_config=None, stat_config=None)[source]

Configures the result object and objects it contains.

Parameters:
  • status_rc – If set to False, return_code always returns 0.
  • suite_config – A dictionary of configuration options passed to configure() method of the contained suite.
  • stat_config – A dictionary of configuration options used when creating statistics.
save(path=None)[source]

Save results as a new output XML file.

Parameters:path – Path to save results to. If omitted, overwrites the original file.
visit(visitor)[source]

An entry point to visit the whole result object.

Parameters:visitor – An instance of ResultVisitor.

Visitors can gather information, modify results, etc. See result package for a simple usage example.

Notice that it is also possible to call result.suite.visit if there is no need to visit the contained statistics or errors.

handle_suite_teardown_failures()[source]

Internal usage only.

class robot.result.executionresult.CombinedResult(results=None)[source]

Bases: robot.result.executionresult.Result

Combined results of multiple test executions.

add_result(other)[source]
configure(status_rc=True, suite_config=None, stat_config=None)

Configures the result object and objects it contains.

Parameters:
  • status_rc – If set to False, return_code always returns 0.
  • suite_config – A dictionary of configuration options passed to configure() method of the contained suite.
  • stat_config – A dictionary of configuration options used when creating statistics.
handle_suite_teardown_failures()

Internal usage only.

return_code

Return code (integer) of test execution.

By default returns the number of failed critical tests (max 250), but can be configured to always return 0.

save(path=None)

Save results as a new output XML file.

Parameters:path – Path to save results to. If omitted, overwrites the original file.
statistics

Test execution statistics.

Statistics are an instance of Statistics that is created based on the contained suite and possible configuration.

Statistics are created every time this property is accessed. Saving them to a variable is thus often a good idea to avoid re-creating them unnecessarily:

from robot.api import ExecutionResult

result = ExecutionResult('output.xml')
result.configure(stat_config={'suite_stat_level': 2,
                              'tag_stat_combine': 'tagANDanother'})
stats = result.statistics
print stats.total.critical.failed
print stats.total.critical.passed
print stats.tags.combined[0].total
visit(visitor)

An entry point to visit the whole result object.

Parameters:visitor – An instance of ResultVisitor.

Visitors can gather information, modify results, etc. See result package for a simple usage example.

Notice that it is also possible to call result.suite.visit if there is no need to visit the contained statistics or errors.

robot.result.flattenkeywordmatcher module

robot.result.flattenkeywordmatcher.validate_flatten_keyword(options)[source]
class robot.result.flattenkeywordmatcher.FlattenByTypeMatcher(flatten)[source]

Bases: object

match(kwtype)[source]
class robot.result.flattenkeywordmatcher.FlattenByNameMatcher(flatten)[source]

Bases: object

match(kwname, libname=None)[source]
class robot.result.flattenkeywordmatcher.FlattenByTagMatcher(flatten)[source]

Bases: object

match(kwtags)[source]

robot.result.keywordremover module

robot.result.keywordremover.KeywordRemover(how)[source]
class robot.result.keywordremover.AllKeywordsRemover[source]

Bases: robot.result.keywordremover._KeywordRemover

visit_keyword(keyword)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_suite(suite)

Called when suite ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_keyword(keyword)

Called when keyword starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_suite(suite)

Called when suite starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

visit_test(test)

Implements traversing through the test and its keywords.

Can be overridden to allow modifying the passed in test without calling start_test() or end_test() nor visiting keywords.

class robot.result.keywordremover.PassedKeywordRemover[source]

Bases: robot.result.keywordremover._KeywordRemover

start_suite(suite)[source]
visit_test(test)[source]
visit_keyword(keyword)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_suite(suite)

Called when suite ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_keyword(keyword)

Called when keyword starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

class robot.result.keywordremover.ByNameKeywordRemover(pattern)[source]

Bases: robot.result.keywordremover._KeywordRemover

start_keyword(kw)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_suite(suite)

Called when suite ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_suite(suite)

Called when suite starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_keyword(kw)

Implements traversing through the keyword and its child keywords.

Can be overridden to allow modifying the passed in kw without calling start_keyword() or end_keyword() nor visiting child keywords.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

visit_test(test)

Implements traversing through the test and its keywords.

Can be overridden to allow modifying the passed in test without calling start_test() or end_test() nor visiting keywords.

class robot.result.keywordremover.ByTagKeywordRemover(pattern)[source]

Bases: robot.result.keywordremover._KeywordRemover

start_keyword(kw)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_suite(suite)

Called when suite ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_suite(suite)

Called when suite starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_keyword(kw)

Implements traversing through the keyword and its child keywords.

Can be overridden to allow modifying the passed in kw without calling start_keyword() or end_keyword() nor visiting child keywords.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

visit_test(test)

Implements traversing through the test and its keywords.

Can be overridden to allow modifying the passed in test without calling start_test() or end_test() nor visiting keywords.

class robot.result.keywordremover.ForLoopItemsRemover[source]

Bases: robot.result.keywordremover._KeywordRemover

start_keyword(kw)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_suite(suite)

Called when suite ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_suite(suite)

Called when suite starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_keyword(kw)

Implements traversing through the keyword and its child keywords.

Can be overridden to allow modifying the passed in kw without calling start_keyword() or end_keyword() nor visiting child keywords.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

visit_test(test)

Implements traversing through the test and its keywords.

Can be overridden to allow modifying the passed in test without calling start_test() or end_test() nor visiting keywords.

class robot.result.keywordremover.WaitUntilKeywordSucceedsRemover[source]

Bases: robot.result.keywordremover._KeywordRemover

start_keyword(kw)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_suite(suite)

Called when suite ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_suite(suite)

Called when suite starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_keyword(kw)

Implements traversing through the keyword and its child keywords.

Can be overridden to allow modifying the passed in kw without calling start_keyword() or end_keyword() nor visiting child keywords.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

visit_test(test)

Implements traversing through the test and its keywords.

Can be overridden to allow modifying the passed in test without calling start_test() or end_test() nor visiting keywords.

class robot.result.keywordremover.WarningAndErrorFinder[source]

Bases: robot.model.visitor.SuiteVisitor

start_suite(suite)[source]
start_test(test)[source]
start_keyword(keyword)[source]
visit_message(msg)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_suite(suite)

Called when suite ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_keyword(kw)

Implements traversing through the keyword and its child keywords.

Can be overridden to allow modifying the passed in kw without calling start_keyword() or end_keyword() nor visiting child keywords.

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

visit_test(test)

Implements traversing through the test and its keywords.

Can be overridden to allow modifying the passed in test without calling start_test() or end_test() nor visiting keywords.

class robot.result.keywordremover.RemovalMessage(message)[source]

Bases: object

set_if_removed(kw, len_before)[source]
set(kw, message=None)[source]

robot.result.merger module

class robot.result.merger.Merger(result)[source]

Bases: robot.model.visitor.SuiteVisitor

merge(merged)[source]
start_suite(suite)[source]
end_suite(suite)[source]
visit_test(test)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_keyword(keyword)

Called when keyword starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_keyword(kw)

Implements traversing through the keyword and its child keywords.

Can be overridden to allow modifying the passed in kw without calling start_keyword() or end_keyword() nor visiting child keywords.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

robot.result.messagefilter module

class robot.result.messagefilter.MessageFilter(loglevel)[source]

Bases: robot.model.visitor.SuiteVisitor

start_keyword(keyword)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_suite(suite)

Called when suite ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_suite(suite)

Called when suite starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_keyword(kw)

Implements traversing through the keyword and its child keywords.

Can be overridden to allow modifying the passed in kw without calling start_keyword() or end_keyword() nor visiting child keywords.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

visit_test(test)

Implements traversing through the test and its keywords.

Can be overridden to allow modifying the passed in test without calling start_test() or end_test() nor visiting keywords.

robot.result.model module

Module implementing result related model objects.

During test execution these objects are created internally by various runners. At that time they can inspected and modified by listeners.

When results are parsed from XML output files after execution to be able to create logs and reports, these objects are created by the ExecutionResult() factory method. At that point they can be inspected and modified by pre-Rebot modifiers.

The ExecutionResult() factory method can also be used by custom scripts and tools. In such usage it is often easiest to inspect and modify these objects using the visitor interface.

class robot.result.model.Message(message='', level='INFO', html=False, timestamp=None, parent=None)[source]

Bases: robot.model.message.Message

Represents a single log message.

See the base class for documentation of attributes not documented here.

html
html_message

Returns the message content as HTML.

level
message
parent
timestamp
visit(visitor)[source]

Visitor interface entry-point.

class robot.result.model.Keyword(kwname='', libname='', doc='', args=(), assign=(), tags=(), timeout=None, type='kw', status='FAIL', starttime=None, endtime=None)[source]

Bases: robot.model.keyword.Keyword

Represents results of a single keyword.

See the base class for documentation of attributes not documented here.

message_class

alias of Message

kwname

Name of the keyword without library or resource name.

libname

Name of the library or resource containing this keyword.

status

Execution status as a string. Typically PASS or FAIL, but library keywords have status NOT_RUN in the dry-ryn mode. See also passed.

starttime

Keyword execution start time in format %Y%m%d %H:%M:%S.%f.

endtime

Keyword execution end time in format %Y%m%d %H:%M:%S.%f.

message

Keyword status message. Used only if suite teardowns fails.

elapsedtime

Total execution time in milliseconds.

name

Keyword name in format libname.kwname.

Just kwname if libname is empty. In practice that is the case only with user keywords in the same file as the executed test case or test suite.

Cannot be set directly. Set libname and kwname separately instead.

passed

True or False depending on the status.

FOR_ITEM_TYPE = 'foritem'
FOR_LOOP_TYPE = 'for'
KEYWORD_TYPE = 'kw'
SETUP_TYPE = 'setup'
TEARDOWN_TYPE = 'teardown'
args
assign
children

Child keywords and messages in creation order.

doc
id

Keyword id in format like s1-t3-k1.

See TestSuite.id for more information.

keyword_class = None
keywords

Child keywords as a Keywords object.

messages

Messages as a Messages object.

parent

Parent test suite, test case or keyword.

tags

Keyword tags as a Tags object.

timeout
type
visit(visitor)[source]

Visitor interface entry-point.

class robot.result.model.TestCase(name='', doc='', tags=None, timeout=None, status='FAIL', message='', starttime=None, endtime=None)[source]

Bases: robot.model.testcase.TestCase

Represents results of a single test case.

See the base class for documentation of attributes not documented here.

keyword_class

alias of Keyword

status

Status as a string PASS or FAIL. See also passed.

message

Test message. Typically a failure message but can be set also when test passes.

starttime

Test case execution start time in format %Y%m%d %H:%M:%S.%f.

endtime

Test case execution end time in format %Y%m%d %H:%M:%S.%f.

elapsedtime

Total execution time in milliseconds.

passed

True/False depending on the status.

critical

True/False depending on is the test considered critical.

Criticality is determined based on test’s tags and criticality of the parent suite.

doc
id

Test case id in format like s1-t3.

See TestSuite.id for more information.

keywords

Keywords as a Keywords object.

Contains also possible setup and teardown keywords.

longname

Test name prefixed with the long name of the parent suite.

name
parent
tags

Test tags as a Tags object.

timeout
visit(visitor)[source]

Visitor interface entry-point.

class robot.result.model.TestSuite(name='', doc='', metadata=None, source=None, message='', starttime=None, endtime=None)[source]

Bases: robot.model.testsuite.TestSuite

Represents results of a single test suite.

See the base class for documentation of attributes not documented here.

test_class

alias of TestCase

keyword_class

alias of Keyword

message

Possible suite setup or teardown error message.

starttime

Suite execution start time in format %Y%m%d %H:%M:%S.%f.

endtime

Suite execution end time in format %Y%m%d %H:%M:%S.%f.

passed

True if no critical test has failed, False otherwise.

status

'PASS' if no critical test has failed, 'FAIL' otherwise.

statistics

Suite statistics as a TotalStatistics object.

Recreated every time this property is accessed, so saving the results to a variable and inspecting it is often a good idea:

stats = suite.statistics
print stats.critical.failed
print stats.all.total
print stats.message
full_message

Combination of message and stat_message.

stat_message

String representation of the statistics.

elapsedtime

Total execution time in milliseconds.

criticality

Used by tests to determine are they considered critical or not.

Normally configured using --critical and --noncritical command line options. Can be set programmatically using set_criticality() of the root test suite.

set_criticality(critical_tags=None, non_critical_tags=None)[source]

Sets which tags are considered critical and which non-critical.

Parameters:
  • critical_tags – Tags or patterns considered critical. See the documentation of the --critical option for more details.
  • non_critical_tags – Tags or patterns considered non-critical. See the documentation of the --noncritical option for more details.

Tags can be given as lists of strings or, when giving only one, as single strings. This information is used by tests to determine are they considered critical or not.

Criticality can be set only to the root test suite.

remove_keywords(how)[source]

Remove keywords based on the given condition.

Parameters:how – What approach to use when removing keywords. Either ALL, PASSED, FOR, WUKS, or NAME:<pattern>.

For more information about the possible values see the documentation of the --removekeywords command line option.

filter_messages(log_level='TRACE')[source]

Remove log messages below the specified log_level.

configure(**options)[source]

A shortcut to configure a suite using one method call.

Parameters:options – Passed to SuiteConfigurer that will then set suite attributes, call filter(), etc. as needed.

Example:

suite.configure(remove_keywords='PASSED',
                critical_tags='smoke',
                doc='Smoke test results.')
doc
filter(included_suites=None, included_tests=None, included_tags=None, excluded_tags=None)[source]

Select test cases and remove others from this suite.

Parameters have the same semantics as --suite, --test, --include, and --exclude command line options. All of them can be given as a list of strings, or when selecting only one, as a single string.

Child suites that contain no tests after filtering are automatically removed.

Example:

suite.filter(included_tests=['Test 1', '* Example'],
             included_tags='priority-1')
handle_suite_teardown_failures()[source]

Internal usage only.

id

An automatically generated unique id.

The root suite has id s1, its child suites have ids s1-s1, s1-s2, ..., their child suites get ids s1-s1-s1, s1-s1-s2, ..., s1-s2-s1, ..., and so on.

The first test in a suite has an id like s1-t1, the second has an id s1-t2, and so on. Similarly keywords in suites (setup/teardown) and in tests get ids like s1-k1, s1-t1-k1, and s1-s4-t2-k5.

keywords

Suite setup and teardown as a Keywords object.

longname

Suite name prefixed with the long name of the parent suite.

metadata

Free test suite metadata as a dictionary.

name

Test suite name. If not set, constructed from child suite names.

parent
remove_empty_suites()[source]

Removes all child suites not containing any tests, recursively.

set_tags(add=None, remove=None, persist=False)[source]

Add and/or remove specified tags to the tests in this suite.

Parameters:
  • add – Tags to add as a list or, if adding only one, as a single string.
  • remove – Tags to remove as a list or as a single string. Can be given as patterns where * and ? work as wildcards.
  • persist – Add/remove specified tags also to new tests added to this suite in the future.
source
suites

Child suites as a TestSuites object.

test_count

Number of the tests in this suite, recursively.

tests

Tests as a TestCases object.

visit(visitor)[source]

Visitor interface entry-point.

suite_teardown_failed(message)[source]

Internal usage only.

robot.result.resultbuilder module

robot.result.resultbuilder.ExecutionResult(*sources, **options)[source]

Factory method to constructs Result objects.

Parameters:
  • sources – Path(s) to the XML output file(s).
  • options – Configuration options. Using merge=True causes multiple results to be combined so that tests in the latter results replace the ones in the original. Other options are passed directly to the ExecutionResultBuilder object used internally.
Returns:

Result instance.

Should be imported by external code via the robot.api package. See the robot.result package for a usage example.

class robot.result.resultbuilder.ExecutionResultBuilder(source, include_keywords=True, flattened_keywords=None)[source]

Bases: object

Builds Result objects based on output files.

Instead of using this builder directly, it is recommended to use the ExecutionResult() factory method.

Parameters:
  • source – Path to the XML output file to build Result objects from.
  • include_keywords – Boolean controlling whether to include keyword information in the result or not. Keywords are not needed when generating only report.
  • flatten_keywords – List of patterns controlling what keywords to flatten. See the documentation of --flattenkeywords option for more details.
build(result)[source]
class robot.result.resultbuilder.RemoveKeywords[source]

Bases: robot.model.visitor.SuiteVisitor

start_suite(suite)[source]
visit_test(test)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_suite(suite)

Called when suite ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_keyword(keyword)

Called when keyword starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_keyword(kw)

Implements traversing through the keyword and its child keywords.

Can be overridden to allow modifying the passed in kw without calling start_keyword() or end_keyword() nor visiting child keywords.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

robot.result.suiteteardownfailed module

class robot.result.suiteteardownfailed.SuiteTeardownFailureHandler[source]

Bases: robot.model.visitor.SuiteVisitor

end_suite(suite)[source]
visit_test(test)[source]
visit_keyword(keyword)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_keyword(keyword)

Called when keyword starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_suite(suite)

Called when suite starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

class robot.result.suiteteardownfailed.SuiteTeardownFailed(error)[source]

Bases: robot.model.visitor.SuiteVisitor

visit_test(test)[source]
visit_keyword(keyword)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_suite(suite)

Called when suite ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_keyword(keyword)

Called when keyword starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_suite(suite)

Called when suite starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

robot.result.visitor module

Visitors can be used to easily traverse result structures.

This module contains ResultVisitor for traversing the whole Result object. It extends SuiteVisitor that contains visiting logic for the test suite structure.

class robot.result.visitor.ResultVisitor[source]

Bases: robot.model.visitor.SuiteVisitor

Abstract class to conveniently travel Result objects.

A visitor implementation can be given to the visit() method of a result object. This will cause the result object to be traversed and the visitor’s visit_x(), start_x(), and end_x() methods to be called for each suite, test, keyword and message, as well as for errors, statistics, and other information in the result object. See methods below for a full list of available visitor methods.

See the result package level documentation for more information about handling results and a concrete visitor example. For more information about the visitor algorithm see documentation in robot.model.visitor module.

visit_result(result)[source]
start_result(result)[source]
end_result(result)[source]
visit_statistics(stats)[source]
start_statistics(stats)[source]
end_statistics(stats)[source]
visit_total_statistics(stats)[source]
start_total_statistics(stats)[source]
end_total_statistics(stats)[source]
visit_tag_statistics(stats)[source]
start_tag_statistics(stats)[source]
end_tag_statistics(stats)[source]
visit_suite_statistics(stats)[source]
start_suite_statistics(stats)[source]
end_suite_statistics(suite_stats)[source]
visit_stat(stat)[source]
start_stat(stat)[source]
end_stat(stat)[source]
visit_errors(errors)[source]
start_errors(errors)[source]
end_errors(errors)[source]
end_keyword(keyword)

Called when keyword ends. Default implementation does nothing.

end_message(msg)

Called when message ends. Default implementation does nothing.

end_suite(suite)

Called when suite ends. Default implementation does nothing.

end_test(test)

Called when test ends. Default implementation does nothing.

start_keyword(keyword)

Called when keyword starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_message(msg)

Called when message starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_suite(suite)

Called when suite starts. Default implementation does nothing.

Can return explicit False to stop visiting.

start_test(test)

Called when test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

visit_keyword(kw)

Implements traversing through the keyword and its child keywords.

Can be overridden to allow modifying the passed in kw without calling start_keyword() or end_keyword() nor visiting child keywords.

visit_message(msg)

Implements visiting the message.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_suite(suite)

Implements traversing through the suite and its direct children.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or keywords (setup and teardown) at all.

visit_test(test)

Implements traversing through the test and its keywords.

Can be overridden to allow modifying the passed in test without calling start_test() or end_test() nor visiting keywords.

robot.result.xmlelementhandlers module

class robot.result.xmlelementhandlers.XmlElementHandler(execution_result, root_handler=None)[source]

Bases: object

start(elem)[source]
end(elem)[source]
class robot.result.xmlelementhandlers.RootHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

end(elem, result)
get_child_handler(elem)
start(elem, result)
class robot.result.xmlelementhandlers.RobotHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'robot'
start(elem, result)[source]
end(elem, result)
get_child_handler(elem)
class robot.result.xmlelementhandlers.SuiteHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'suite'
start(elem, result)[source]
end(elem, result)
get_child_handler(elem)
class robot.result.xmlelementhandlers.RootSuiteHandler[source]

Bases: robot.result.xmlelementhandlers.SuiteHandler

start(elem, result)[source]
end(elem, result)
get_child_handler(elem)
tag = 'suite'
class robot.result.xmlelementhandlers.TestCaseHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'test'
start(elem, result)[source]
end(elem, result)
get_child_handler(elem)
class robot.result.xmlelementhandlers.KeywordHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'kw'
start(elem, result)[source]
end(elem, result)
get_child_handler(elem)
class robot.result.xmlelementhandlers.MessageHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'msg'
end(elem, result)[source]
get_child_handler(elem)
start(elem, result)
class robot.result.xmlelementhandlers.KeywordStatusHandler[source]

Bases: robot.result.xmlelementhandlers._StatusHandler

end(elem, result)[source]
get_child_handler(elem)
start(elem, result)
tag = 'status'
class robot.result.xmlelementhandlers.SuiteStatusHandler[source]

Bases: robot.result.xmlelementhandlers._StatusHandler

end(elem, result)[source]
get_child_handler(elem)
start(elem, result)
tag = 'status'
class robot.result.xmlelementhandlers.TestStatusHandler[source]

Bases: robot.result.xmlelementhandlers._StatusHandler

end(elem, result)[source]
get_child_handler(elem)
start(elem, result)
tag = 'status'
class robot.result.xmlelementhandlers.DocHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'doc'
end(elem, result)[source]
get_child_handler(elem)
start(elem, result)
class robot.result.xmlelementhandlers.MetadataHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'metadata'
end(elem, result)
get_child_handler(elem)
start(elem, result)
class robot.result.xmlelementhandlers.MetadataItemHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'item'
end(elem, result)[source]
get_child_handler(elem)
start(elem, result)
class robot.result.xmlelementhandlers.TagsHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'tags'
end(elem, result)
get_child_handler(elem)
start(elem, result)
class robot.result.xmlelementhandlers.TagHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'tag'
end(elem, result)[source]
get_child_handler(elem)
start(elem, result)
class robot.result.xmlelementhandlers.TimeoutHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'timeout'
end(elem, result)[source]
get_child_handler(elem)
start(elem, result)
class robot.result.xmlelementhandlers.AssignHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'assign'
end(elem, result)
get_child_handler(elem)
start(elem, result)
class robot.result.xmlelementhandlers.AssignVarHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'var'
end(elem, result)[source]
get_child_handler(elem)
start(elem, result)
class robot.result.xmlelementhandlers.ArgumentsHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'arguments'
end(elem, result)
get_child_handler(elem)
start(elem, result)
class robot.result.xmlelementhandlers.ArgumentHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'arg'
end(elem, result)[source]
get_child_handler(elem)
start(elem, result)
class robot.result.xmlelementhandlers.ErrorsHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'errors'
start(elem, result)[source]
end(elem, result)
get_child_handler(elem)
class robot.result.xmlelementhandlers.StatisticsHandler[source]

Bases: robot.result.xmlelementhandlers._Handler

tag = 'statistics'
get_child_handler(elem)[source]
end(elem, result)
start(elem, result)