Deleted Added
sdiff udiff text old ( 12882:dd87d7f2f3e5 ) new ( 14141:b3ceff47211a )
full compact
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 '''
182 def __init__(self, suites, global_fixtures):
183 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
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 self.global_fixtures,
211 *(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):
224 return self.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