Robot Framework Integrated Development Environment (RIDE)
suitestatistics.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 .stats import SuiteStat
17 
18 
19 
21 
22  def __init__(self, suite):
23  #: Instance of :class:`~robot.model.stats.SuiteStat`.
24  self.statstat = SuiteStat(suite)
25  #: List of :class:`~robot.model.testsuite.TestSuite` objects.
26  self.suitessuites = []
27 
28  def visit(self, visitor):
29  visitor.visit_suite_statistics(self)
30 
31  def __iter__(self):
32  yield self.statstat
33  for child in self.suitessuites:
34  for stat in child:
35  yield stat
36 
37 
39 
40  def __init__(self, suite_stat_level):
41  self._suite_stat_level_suite_stat_level = suite_stat_level
42  self._stats_stack_stats_stack = []
43  self.statsstats = None
44 
45  @property
46  current = property
47 
48  def current(self):
49  return self._stats_stack_stats_stack[-1] if self._stats_stack_stats_stack else None
50 
51  def start_suite(self, suite):
52  self._stats_stack_stats_stack.append(SuiteStatistics(suite))
53  if self.statsstats is None:
54  self.statsstats = self.currentcurrentcurrent
55 
56  def add_test(self, test):
57  self.currentcurrentcurrent.stat.add_test(test)
58 
59  def end_suite(self):
60  stats = self._stats_stack_stats_stack.pop()
61  if self.currentcurrentcurrent:
62  self.currentcurrentcurrent.stat.add_stat(stats.stat)
63  if self._is_child_included_is_child_included():
64  self.currentcurrentcurrent.suites.append(stats)
65 
66  def _is_child_included(self):
67  return self._include_all_levels_include_all_levels() or self._below_threshold_below_threshold()
68 
70  return self._suite_stat_level_suite_stat_level == -1
71 
72  def _below_threshold(self):
73  return len(self._stats_stack_stats_stack) < self._suite_stat_level_suite_stat_level
Stores statistics values for a single suite.
Definition: stats.py:106