Package qm :: Package test :: Module expectation_database
[hide private]
[frames] | no frames]

Source Code for Module qm.test.expectation_database

 1  ######################################################################## 
 2  # 
 3  # File:   expectation_database.py 
 4  # Author: Stefan Seefeld 
 5  # Date:   2006-11-05 
 6  # 
 7  # Contents: 
 8  #   QMTest ExpectationDatabase class. 
 9  # 
10  # Copyright (c) 2006 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.extension import Extension 
21  from qm.fields import PythonField 
22  from qm.test.result import Result 
23   
24  ######################################################################## 
25  # Classes 
26  ######################################################################## 
27   
28 -class ExpectationDatabase(Extension):
29 """An 'ExpectationDatabase' stores result expectations. 30 31 An 'ExpectationDatabase' provides a mechanism to store and make 32 accessible expectations for test outcomes. 33 By default, all tests are expected to pass. 34 """ 35 36 37 kind = 'expectation_database' 38 39 40 test_database = PythonField() 41 testrun_parameters = PythonField() 42 43
44 - def Lookup(self, test_id):
45 """Look up the expected outcome for the given test. 46 47 'test_id' -- test-id for which the outcome is queried. 48 49 returns -- a Result object associated with this test_id.""" 50 51 return Result(Result.TEST, test_id)
52 53
54 - def GetExpectedOutcomes(self):
55 """Return a dict object mapping test ids to expected outcomes.""" 56 57 outcomes = {} 58 if self.test_database: 59 for test_id in self.test_database.GetTestIds(): 60 outcomes[test_id] = self.Lookup(test_id).GetOutcome() 61 return outcomes
62