wrappers.py (12882:dd87d7f2f3e5) wrappers.py (14141:b3ceff47211a)
1# Copyright (c) 2019 ARM Limited
2# All rights reserved
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license
9# terms below provided that you ensure that this notice is replicated
10# unmodified and in its entirety in all distributions of the software,
11# modified or unmodified, in source code or in binary form.
12#
1# Copyright (c) 2017 Mark D. Hill and David A. Wood
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 165 unchanged lines hidden (view full) ---

174 return self.metadata.tags
175
176
177class LoadedLibrary(LoadedTestable):
178 '''
179 Wraps a collection of all loaded test suites and
180 provides utility functions for accessing fixtures.
181 '''
13# Copyright (c) 2017 Mark D. Hill and David A. Wood
14# All rights reserved.
15#
16# Redistribution and use in source and binary forms, with or without
17# modification, are permitted provided that the following conditions are
18# met: redistributions of source code must retain the above copyright
19# notice, this list of conditions and the following disclaimer;
20# redistributions in binary form must reproduce the above copyright

--- 165 unchanged lines hidden (view full) ---

186 return self.metadata.tags
187
188
189class LoadedLibrary(LoadedTestable):
190 '''
191 Wraps a collection of all loaded test suites and
192 provides utility functions for accessing fixtures.
193 '''
182 def __init__(self, suites, global_fixtures):
194 def __init__(self, suites):
183 LoadedTestable.__init__(self, suites)
195 LoadedTestable.__init__(self, suites)
184 self.global_fixtures = global_fixtures
185
186 def _generate_metadata(self):
187 return LibraryMetadata( **{
188 'name': 'Test Library',
189 'status': Status.Unscheduled,
190 'result': Result(Result.NotRun)
191 })
192
193 def __iter__(self):
194 '''
195 :returns: an iterator over contained :class:`TestSuite` objects.
196 '''
197 return iter(self.obj)
198
196
197 def _generate_metadata(self):
198 return LibraryMetadata( **{
199 'name': 'Test Library',
200 'status': Status.Unscheduled,
201 'result': Result(Result.NotRun)
202 })
203
204 def __iter__(self):
205 '''
206 :returns: an iterator over contained :class:`TestSuite` objects.
207 '''
208 return iter(self.obj)
209
199 def all_fixture_tuples(self):
200 return itertools.chain(
201 self.global_fixtures,
202 *(suite.fixtures for suite in self.obj))
203
204 def all_fixtures(self):
205 '''
206 :returns: an interator overall all global, suite,
207 and test fixtures
208 '''
209 return itertools.chain(itertools.chain(
210 def all_fixtures(self):
211 '''
212 :returns: an interator overall all global, suite,
213 and test fixtures
214 '''
215 return itertools.chain(itertools.chain(
210 self.global_fixtures,
211 *(suite.fixtures for suite in self.obj)),
216 *(suite.fixtures for suite in self.obj)),
212 *(self.test_fixtures(suite) for suite in self.obj)
213 )
214
215 def test_fixtures(self, suite):
216 '''
217 :returns: an interator over all fixtures of each
218 test contained in the given suite
219 '''
220 return itertools.chain(*(test.fixtures for test in suite))
221
222 @property
223 def fixtures(self):
217 *(self.test_fixtures(suite) for suite in self.obj)
218 )
219
220 def test_fixtures(self, suite):
221 '''
222 :returns: an interator over all fixtures of each
223 test contained in the given suite
224 '''
225 return itertools.chain(*(test.fixtures for test in suite))
226
227 @property
228 def fixtures(self):
224 return self.global_fixtures
229 global_fixtures = []
230 for fixture in self.all_fixtures():
231 if fixture.is_global():
232 global_fixtures.append(fixture)
233 return global_fixtures
225
226 @property
227 def uid(self):
228 return self.name
229
230 @property
231 def suites(self):
232 return self.obj
233
234 @suites.setter
235 def suites(self, suites):
236 self.obj = suites
234
235 @property
236 def uid(self):
237 return self.name
238
239 @property
240 def suites(self):
241 return self.obj
242
243 @suites.setter
244 def suites(self, suites):
245 self.obj = suites