All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QMTTest.py
Go to the documentation of this file.
1 import BaseTest
2 from BaseTest import *
3 
5 
6  def __init__(self):
7  BaseTest.__init__(self)
8  self.validator =''
9 
10  def XMLParser(self,path) :
11 
12  dic = self.__dict__
13 
14  tree = ET.parse(RationalizePath(path))
15  root = tree.getroot()
16 
17  for child in root:
18  type = child.attrib['name']
19  dic['name']=path
20  if type in dic :
21  if type == 'args' or type == 'unsupported_platforms':
22  textList = child[0].findall('text')
23  for tl in textList :
24  dic[type]+=[tl.text]
25  elif type == 'environment':
26  dic[type]={}
27  envList= child[0].findall('text')
28  for el in envList :
29  indexDictPart= el.text.rfind("=")
30  dic[type][el.text[:indexDictPart]]=el.text[indexDictPart+1:]
31  else :
32  dic[type] = child[0].text
33 
34 
35  def ValidateOutput(self, stdout, stderr, result):
36  if self.validator != '' :
37  class CallWrapper(object):
38  """
39  Small wrapper class to dynamically bind some default arguments
40  to a callable.
41  """
42  def __init__(self, callable, extra_args = {}):
43  self.callable = callable
44  self.extra_args = extra_args
45  # get the list of names of positional arguments
46  from inspect import getargspec
47  self.args_order = getargspec(callable)[0]
48  # Remove "self" from the list of positional arguments
49  # since it is added automatically
50  if self.args_order[0] == "self":
51  del self.args_order[0]
52  def __call__(self, *args, **kwargs):
53  # Check which positional arguments are used
54  positional = self.args_order[:len(args)]
55 
56  kwargs = dict(kwargs) # copy the arguments dictionary
57  for a in self.extra_args:
58  # use "extra_args" for the arguments not specified as
59  # positional or keyword
60  if a not in positional and a not in kwargs:
61  kwargs[a] = self.extra_args[a]
62  return apply(self.callable, args, kwargs)
63 
64  # local names to be exposed in the script
65  exported_symbols = {"self":self,
66  "stdout":stdout,
67  "stderr":stderr,
68  "result":result,
69  "causes":self.causes,
70  "findReferenceBlock":
71  CallWrapper(self.findReferenceBlock, {"stdout":stdout,
72  "result":result,
73  "causes":self.causes}),
74  "validateWithReference":
75  CallWrapper(self.validateWithReference, {"stdout":stdout,
76  "stderr":stderr,
77  "result":result,
78  "causes":self.causes}),
79  "countErrorLines":
80  CallWrapper(self.countErrorLines, {"stdout":stdout,
81  "result":result,
82  "causes":self.causes}),
83  "checkTTreesSummaries":
84  CallWrapper(self.CheckTTreesSummaries, {"stdout":stdout,
85  "result":result,
86  "causes":self.causes}),
87  "checkHistosSummaries":
88  CallWrapper(self.CheckHistosSummaries, {"stdout":stdout,
89  "result":result,
90  "causes":self.causes})
91  }
92  exec self.validator in globals(),exported_symbols
93  else:
94  if self.stderr=='':
95  self.validateWithReference(stdout, stderr, result, self.causes)
96  elif stderr!=self.stderr:
97  self.causes.append("DIFFERENT STDERR THAN EXPECTED")
98 
99  return result,self.causes
def __init__
Definition: QMTTest.py:6
def validateWithReference
Definition: BaseTest.py:330
def ValidateOutput
Definition: QMTTest.py:35
def RationalizePath
Definition: BaseTest.py:425
def CheckTTreesSummaries
Definition: BaseTest.py:257
def CheckHistosSummaries
Definition: BaseTest.py:294
def findReferenceBlock
Definition: BaseTest.py:178