Robot Framework
executionerrors.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 from robot.model import ItemList, Message
17 from robot.utils import setter
18 
19 
20 
25  id = 'errors'
26 
27  def __init__(self, messages=None):
28  #: A :class:`list-like object <robot.model.itemlist.ItemList>` of
29  #: :class:`~robot.model.message.Message` instances.
30  self.messagesmessagesmessages = messages
31 
32  @setter
33  def messages(self, messages):
34  return ItemList(Message, {'parent': self}, items=messages)
35 
36  def add(self, other):
37  self.messagesmessagesmessages.extend(other.messages)
38 
39  def visit(self, visitor):
40  visitor.visit_errors(self)
41 
42  def __iter__(self):
43  return iter(self.messagesmessagesmessages)
44 
45  def __len__(self):
46  return len(self.messagesmessagesmessages)
47 
48  def __getitem__(self, index):
49  return self.messagesmessagesmessages[index]
50 
51  def __str__(self):
52  if not self:
53  return 'No execution errors'
54  if len(self) == 1:
55  return f'Execution error: {self[0]}'
56  return '\n'.join(['Execution errors:'] + ['- ' + str(m) for m in self])
Represents errors occurred during the execution of tests.