Skip to content

Commit 370c886

Browse files
committed
Added ivar documentation for Statistics, ExecutionErrors and Message
Update issue 1468 Added documentation for Statistics, ExecutionErrors and Message internal variables.
1 parent 41dfaf9 commit 370c886

7 files changed

Lines changed: 97 additions & 0 deletions

File tree

src/robot/model/message.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919

2020

2121
class Message(ModelObject):
22+
"""A message outputted during the test execution.
23+
24+
The message can be a log message triggered by a keyword, or a warning
25+
or an error occurred during the test execution.
26+
27+
:ivar message: The message content as a string.
28+
:ivar level: Severity of the message. Either ``TRACE``, ``INFO``,
29+
``WARN``, ``DEBUG`` or ``FAIL``/``ERROR``.
30+
:ivar html: ``True`` if the content is in HTML, ``False`` otherwise.
31+
:ivar timestamp: Timestamp in format ``%Y%m%d %H:%M:%S.%f``.
32+
:ivar parent: The object this message was triggered by.
33+
"""
2234
__slots__ = ['message', 'level', 'html', 'timestamp', 'parent']
2335

2436
def __init__(self, message='', level='INFO', html=False, timestamp=None,
@@ -31,6 +43,8 @@ def __init__(self, message='', level='INFO', html=False, timestamp=None,
3143

3244
@property
3345
def html_message(self):
46+
"""Returns the message content as HTML.
47+
"""
3448
return self.message if self.html else html_escape(self.message)
3549

3650
def visit(self, visitor):

src/robot/model/statistics.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919

2020

2121
class Statistics(object):
22+
"""Container for total, suite and tag statistics.
23+
24+
Accepted parameters have the same semantics as the matching command line
25+
options.
26+
27+
:ivar total: Instance of :class:`~robot.model.totalstatistics.TotalStatistics`.
28+
:ivar suite: Instance of :class:`~robot.model.suitestatistics.SuiteStatistics`.
29+
:ivar tags: Instance of :class:`~robot.model.tagstatistics.TagStatistics`.
30+
"""
2231

2332
def __init__(self, suite, suite_stat_level=-1, tag_stat_include=None,
2433
tag_stat_exclude=None, tag_stat_combine=None, tag_doc=None,

src/robot/model/stats.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@
1818

1919

2020
class Stat(object):
21+
"""Generic statistic object used for storing all the statistic values.
22+
23+
:ivar name: Human readable identifier of the object these statistics
24+
belong to. Either `All Tests` or `Critical Tests` for
25+
:class:`~robot.model.totalstatistics.TotalStatistics`,
26+
long name of the suite for
27+
:class:`~robot.model.suitestatistics.SuiteStatistics`
28+
or name of the tag for
29+
:class:`~robot.model.tagstatistics.TagStatistics`
30+
:ivar passed: Number of passed tests.
31+
:ivar failed: Number of failed tests.
32+
:ivar elapsed: Number of milliseconds it took to execute.
33+
"""
2134

2235
def __init__(self, name):
2336
self.name = name
@@ -78,10 +91,21 @@ def visit(self, visitor):
7891

7992

8093
class TotalStat(Stat):
94+
"""Stores statistic values for a test run.
95+
96+
:ivar type: Always string `total`.
97+
"""
8198
type = 'total'
8299

83100

84101
class SuiteStat(Stat):
102+
"""Stores statistics values for a single suite.
103+
104+
:ivar id: Identifier of the suite, e.g. `s1-s2`.
105+
:ivar elapsed: Number of milliseconds it took to execute this suite,
106+
including sub-suites.
107+
:ivar type: Always string `suite`
108+
"""
85109
type = 'suite'
86110

87111
def __init__(self, suite):
@@ -102,6 +126,18 @@ def add_stat(self, other):
102126

103127

104128
class TagStat(Stat):
129+
"""Stores statistic values for a single tag.
130+
131+
:ivar doc: Documentation of tag as a string.
132+
:ivar links: List of tuples in which the first value is the link URL and
133+
the second is the link title. An empty list by default.
134+
:ivar critical: ``True`` if tag is considered critical, ``False`` otherwise.
135+
:ivar non_critical: ``True`` if tag is considered non-critical, ``False``
136+
otherwise.
137+
:ivar combined: Pattern as a string if the tag is combined, an empty string
138+
otherwise.
139+
:ivar type: Always string `tag`.
140+
"""
105141
type = 'tag'
106142

107143
def __init__(self, name, doc='', links=None, critical=False,
@@ -115,6 +151,10 @@ def __init__(self, name, doc='', links=None, critical=False,
115151

116152
@property
117153
def info(self):
154+
"""Returns additional information of the tag statistics
155+
are about. Either `critical`, `non-critical`, `combined` or an
156+
empty string.
157+
"""
118158
if self.critical:
119159
return 'critical'
120160
if self.non_critical:

src/robot/model/suitestatistics.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717

1818
class SuiteStatistics(object):
19+
"""Container for suite statistics.
20+
21+
:ivar stat: Instance of :class:`~robot.model.stats.SuiteStat`.
22+
:ivar suites: List of :class:`~robot.model.testsuite.TestSuite` objects.
23+
"""
1924

2025
def __init__(self, suite):
2126
self.stat = SuiteStat(suite)

src/robot/model/tagstatistics.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222

2323

2424
class TagStatistics(object):
25+
"""Container for tag statistics.
26+
27+
:ivar tags: Dictionary, where key is the name of the tag
28+
as a string and value is an instance of
29+
:class:`~robot.model.stats.TagStat`.
30+
:ivar combined: Dictionary, where key is the name
31+
of the created tag as a string and value is an instance of
32+
:class:`~robot.model.stats.TagStat`.
33+
"""
2534

2635
def __init__(self, combined_stats):
2736
self.tags = NormalizedDict(ignore=['_'])

src/robot/model/totalstatistics.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717

1818

1919
class TotalStatistics(object):
20+
"""Container for total statistics.
21+
22+
:ivar critical: Instance of :class:`~robot.model.stats.TotalStat` for
23+
critical tests.
24+
:ivar all: Instance of :class:`~robot.model.stats.TotalStat` for
25+
all the tests, including critical.
26+
"""
2027

2128
def __init__(self):
2229
self.critical = TotalStat('Critical Tests')
@@ -30,6 +37,12 @@ def __iter__(self):
3037

3138
@property
3239
def message(self):
40+
"""Returns a summary of total statistics in a string representation,
41+
for example::
42+
43+
2 critical tests, 1 passed, 1 failed
44+
2 tests total, 1 passed, 1 failed
45+
"""
3346
ctotal, cend, cpass, cfail = self._get_counts(self.critical)
3447
atotal, aend, apass, afail = self._get_counts(self.all)
3548
return ('%d critical test%s, %d passed, %d failed\n'

src/robot/result/executionerrors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919

2020

2121
class ExecutionErrors(object):
22+
"""Represents errors occurred during the execution of tests.
23+
24+
An error might be, for example, that importing a library has failed.
25+
26+
:ivar messages: A list-like object of :class:`~robot.model.message.Message`
27+
instances.
28+
"""
2229
message_class = Message
2330

2431
def __init__(self, messages=None):

0 commit comments

Comments
 (0)