1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import qm
21 import qm.extension
22
23
24
25
26
27 -class Suite(qm.extension.Extension):
28 """A collection of tests.
29
30 A test suite is a collection of tests. The suite may contain other
31 suites by reference as well; all tests contained in these contained
32 suites are considered contained in the containing suite as well."""
33
34 arguments = [
35 ]
36
37 kind = "suite"
38
39 EXTRA_ID = "qmtest_id"
40 """The name of the extra keyword argument to '__init__' that
41 specifies the name of the test or resource."""
42
43 EXTRA_DATABASE = "qmtest_database"
44 """The name of the extra keyword argument to '__init__' that
45 specifies the database containing the test or resource."""
46
47
59
60
61
63 """Return the 'Database' that contains this suite.
64
65 returns -- The 'Database' that contains this suite."""
66
67 return self.__database
68
69
71 """Return the ID of this test suite."""
72
73 return self.__id
74
75
77 """Return the tests contained in this suite.
78
79 returns -- A sequence of labels corresponding to the tests
80 contained in this suite. Tests that are contained in this suite
81 only because they are contained in a suite which is itself
82 contained in this suite are not returned."""
83
84 return []
85
86
88 """Return the suites contained in this suite.
89
90 returns -- A sequence of labels corresponding to the suites
91 contained in this suite. Suites that are contained in this suite
92 only because they are contained in a suite which is itself
93 contained in this suite are not returned."""
94
95 return []
96
97
99 """Return true if this is an implicit test suite.
100
101 Implicit test suites cannot be edited."""
102
103 raise NotImplementedError
104
105
107 """Return the tests/suites contained in this suite and its subsuites.
108
109 returns -- A pair '(test_ids, suite_ids)'. The 'test_ids' and
110 'suite_ids' elements are both sequences of labels. The values
111 returned include all tests and suites that are contained in this
112 suite and its subsuites, recursively."""
113
114 suite = self
115
116 test_ids = []
117 suite_ids = []
118
119
120 work_list = [suite]
121
122 while len(work_list) > 0:
123 suite = work_list.pop(0)
124
125 test_ids.extend(suite.GetTestIds())
126
127 sub_suite_ids = suite.GetSuiteIds()
128
129 suite_ids.extend(sub_suite_ids)
130
131 sub_suites = map(self.GetDatabase().GetSuite, sub_suite_ids)
132
133 if suite.IsImplicit():
134 sub_suites = filter(lambda s: s.IsImplicit(), sub_suites)
135
136 work_list.extend(sub_suites)
137
138 return test_ids, suite_ids
139