MCPcopy Create free account
hub / github.com/ceph/ceph / DecoratingLoader

Class DecoratingLoader

qa/tasks/cephfs_test_runner.py:14–44  ·  view source on GitHub ↗

A specialization of TestLoader that tags some extra attributes onto test classes as they are loaded.

Source from the content-addressed store, hash-verified

12
13
14class DecoratingLoader(loader.TestLoader):
15 """
16 A specialization of TestLoader that tags some extra attributes
17 onto test classes as they are loaded.
18 """
19 def __init__(self, params):
20 self._params = params
21 super(DecoratingLoader, self).__init__()
22
23 def _apply_params(self, obj):
24 for k, v in self._params.items():
25 if obj.__class__ is type:
26 cls = obj
27 else:
28 cls = obj.__class__
29 setattr(cls, k, v)
30
31 def loadTestsFromTestCase(self, testCaseClass):
32 self._apply_params(testCaseClass)
33 return super(DecoratingLoader, self).loadTestsFromTestCase(testCaseClass)
34
35 def loadTestsFromName(self, name, module=None):
36 result = super(DecoratingLoader, self).loadTestsFromName(name, module)
37
38 # Special case for when we were called with the name of a method, we get
39 # a suite with one TestCase
40 tests_in_result = list(result)
41 if len(tests_in_result) == 1 and isinstance(tests_in_result[0], case.TestCase):
42 self._apply_params(tests_in_result[0])
43
44 return result
45
46
47class LogStream(object):

Callers 2

exec_testFunction · 0.90
taskFunction · 0.85

Calls

no outgoing calls

Tested by 1

taskFunction · 0.68