Robot Framework
message.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.utils import html_escape
17 
18 from .body import BodyItem
19 from .itemlist import ItemList
20 
21 
22 
28  type = BodyItem.MESSAGE
29  repr_args = ('message', 'level')
30  __slots__ = ['message', 'level', 'html', 'timestamp']
31 
32  def __init__(self, message='', level='INFO', html=False, timestamp=None, parent=None):
33  #: The message content as a string.
34  self.messagemessage = message
35  #: Severity of the message. Either ``TRACE``, ``DEBUG``, ``INFO``,
36  #: ``WARN``, ``ERROR``, ``FAIL`` or ``SKIP`. The last two are only used
37  #: with keyword failure messages.
38  self.levellevel = level
39  #: ``True`` if the content is in HTML, ``False`` otherwise.
40  self.htmlhtml = html
41  #: Timestamp in format ``%Y%m%d %H:%M:%S.%f``.
42  self.timestamptimestamp = timestamp
43  #: The object this message was triggered by.
44  self.parentparent = parent
45 
46  @property
47 
48  html_message = property
49 
50  def html_message(self):
51  return self.messagemessage if self.htmlhtml else html_escape(self.messagemessage)
52 
53  @property
54  id = property
55 
56  def id(self):
57  if not self.parentparent:
58  return 'm1'
59  return '%s-m%d' % (self.parentparent.id, self.parentparent.messages.index(self) + 1)
60 
61 
62  def visit(self, visitor):
63  visitor.visit_message(self)
64 
65  def __str__(self):
66  return self.messagemessage
67 
68 
70  __slots__ = []
71 
72  def __init__(self, message_class=Message, parent=None, messages=None):
73  ItemList.__init__(self, message_class, {'parent': parent}, messages)
A message created during the test execution.
Definition: message.py:27
def visit(self, visitor)
:mod:Visitor interface <robot.model.visitor> entry-point.
Definition: message.py:62
def __init__(self, message='', level='INFO', html=False, timestamp=None, parent=None)
Definition: message.py:32
html_message
Returns the message content as HTML.
Definition: message.py:48
def __init__(self, message_class=Message, parent=None, messages=None)
Definition: message.py:72
def html_escape(text, linkify=True)
Definition: markuputils.py:44