diff options
-rw-r--r-- | meta/lib/oeqa/core/decorator/data.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/meta/lib/oeqa/core/decorator/data.py b/meta/lib/oeqa/core/decorator/data.py new file mode 100644 index 0000000000..73cca88d7b --- /dev/null +++ b/meta/lib/oeqa/core/decorator/data.py | |||
@@ -0,0 +1,36 @@ | |||
1 | # Copyright (C) 2016 Intel Corporation | ||
2 | # Released under the MIT license (see COPYING.MIT) | ||
3 | |||
4 | from oeqa.core.exception import OEQAMissingVariable | ||
5 | |||
6 | from . import OETestDecorator, registerDecorator | ||
7 | |||
8 | @registerDecorator | ||
9 | class skipIfDataVar(OETestDecorator): | ||
10 | """ | ||
11 | Skip test based on value of a data store's variable. | ||
12 | |||
13 | It will get the info of var from the data store and will | ||
14 | check it against value; if are equal it will skip the test | ||
15 | with msg as the reason. | ||
16 | """ | ||
17 | |||
18 | attrs = ('var', 'value', 'msg') | ||
19 | |||
20 | def setUpDecorator(self): | ||
21 | msg = 'Checking if %r value is %r to skip test' % (self.var, self.value) | ||
22 | self.logger.debug(msg) | ||
23 | if self.case.td.get(self.var) == self.value: | ||
24 | self.case.skipTest(self.msg) | ||
25 | |||
26 | @registerDecorator | ||
27 | class OETestDataDepends(OETestDecorator): | ||
28 | attrs = ('td_depends',) | ||
29 | |||
30 | def setUpDecorator(self): | ||
31 | for v in self.td_depends: | ||
32 | try: | ||
33 | value = self.case.td[v] | ||
34 | except KeyError: | ||
35 | raise OEQAMissingVariable("Test case need %s variable but"\ | ||
36 | " isn't into td" % v) | ||