Home | Trees | Index | Help |
---|
|
1 ######################################################################## 2 # 3 # File: xml_expectation_database.py 4 # Author: Stefan Seefeld 5 # Date: 2007-09-18 6 # 7 # Contents: 8 # QMTest XMLExpectationDatabase extension class. 9 # 10 # Copyright (c) 2007 by CodeSourcery, Inc. All rights reserved. 11 # 12 # For license terms see the file COPYING. 13 # 14 ######################################################################## 15 16 ######################################################################## 17 # Imports 18 ######################################################################## 19 20 from qm.fields import TextField 21 from qm.test.expectation_database import ExpectationDatabase 22 from qm.test.result import Result 23 from qm.test.base import load_results 24 from qm.xmlutil import * 25 import re 26 27 ######################################################################## 28 # Classes 29 ######################################################################## 3032 """An 'XMLExpectationDatabase' reads expectations from 33 an XML file.""" 34 35 file_name = TextField() 36 377239 40 super(XMLExpectationDatabase, self).__init__(**args) 41 self._expectations = [] 42 document = load_xml(open(self.file_name)) 43 root = document.documentElement 44 for e in root.getElementsByTagName('expectation'): 45 test_id = e.getAttribute('test_id') 46 outcome = {'pass':Result.PASS, 47 'fail':Result.FAIL,}[e.getAttribute('outcome')] 48 filters = {} 49 for a in e.getElementsByTagName('annotation'): 50 filters[a.getAttribute('name')] = a.getAttribute('value') 51 description = e.getElementsByTagName('description') 52 if description: description = get_dom_text(description[0]) 53 self._expectations.append((test_id, outcome, filters, description))54 5557 58 59 outcome, description = Result.PASS, '' 60 for rule_id, rule_outcome, rule_annotations, rule_description in self._expectations: 61 if re.match(rule_id, test_id): 62 match = True 63 for a in rule_annotations.iteritems(): 64 if (a[0] not in self.testrun_parameters or 65 not re.match(a[1], self.testrun_parameters[a[0]])): 66 match = False 67 if match: 68 outcome = rule_outcome 69 description = rule_description 70 return Result(Result.TEST, test_id, outcome, 71 annotations={'description':description})
Home | Trees | Index | Help |
---|
Generated by Epydoc 3.0alpha2 on Fri Sep 28 01:01:16 2007 | http://epydoc.sf.net |