20 from .executionresult
import Result, CombinedResult
21 from .flattenkeywordmatcher
import (FlattenByNameMatcher, FlattenByTypeMatcher,
23 from .merger
import Merger
24 from .xmlelementhandlers
import XmlElementHandler
45 raise DataError(
'One or more data source needed.')
46 if options.pop(
'merge',
False):
67 ets = ETSource(source)
68 result =
Result(source, rpa=options.pop(
'rpa',
None))
71 except IOError
as err:
75 raise DataError(
"Reading XML source '%s' failed: %s" % (
unic(ets), error))
95 def __init__(self, source, include_keywords=True, flattened_keywords=None):
97 if isinstance(source, ETSource)
else ETSource(source)
104 with self.
_source_source
as source:
105 self.
_parse_parse(source, handler.start, handler.end)
106 result.handle_suite_teardown_failures()
112 context = ET.iterparse(source, events=(
'start',
'end'))
117 for event, elem
in context:
126 for event, elem
in context:
128 omit = elem.tag ==
'kw' and elem.get(
'type') !=
'teardown'
129 start = event ==
'start'
136 if omit
and not start:
141 name_match, by_name = self.
_get_matcher_get_matcher(FlattenByNameMatcher, flattened)
142 type_match, by_type = self.
_get_matcher_get_matcher(FlattenByTypeMatcher, flattened)
143 tags_match, by_tags = self.
_get_matcher_get_matcher(FlattenByTagMatcher, flattened)
148 for event, elem
in context:
150 start = event ==
'start'
152 if start
and tag ==
'kw':
156 elif by_name
and name_match(elem.get(
'name',
''), elem.get(
'library')):
159 elif by_type
and type_match(elem.get(
'type',
'kw')):
162 elif started < 0
and by_tags
and inside_kw:
163 if end
and tag ==
'tag':
164 tags.append(elem.text
or '')
165 elif end
and tag ==
'tags':
170 if end
and tag ==
'kw':
172 if started == 0
and not seen_doc:
173 doc = ET.Element(
'doc')
174 doc.text =
'_*Keyword content flattened.*_'
177 if started == 0
and end
and tag ==
'doc':
179 elem.text = (
'%s\n\n_*Keyword content flattened.*_'
180 % (elem.text
or '')).strip()
181 if started <= 0
or tag ==
'msg':
185 if started >= 0
and end
and tag ==
'kw':
189 matcher = matcher_class(flattened)
190 return matcher.match, bool(matcher)
Used when variable does not exist.
Interface to ease traversing through a test suite structure.
Combined results of multiple test executions.
Builds :class:~.executionresult.Result objects based on output files.
def _flatten_keywords(self, context, flattened)
def _omit_keywords(self, context)
def __init__(self, source, include_keywords=True, flattened_keywords=None)
:param source: Path to the XML output file to build :class:~.executionresult.Result objects from.
def _get_matcher(self, matcher_class, flattened)
def _parse(self, source, start, end)
def visit_test(self, test)
Implements traversing through the test and its keywords.
def start_suite(self, suite)
Called when suite starts.
def _merge_results(original, merged, options)
def _single_result(source, options)
def ExecutionResult(*sources, **options)
Factory method to constructs :class:~.executionresult.Result objects.
def _combine_results(sources, options)
def get_error_message()
Returns error message of the last occurred exception.