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

Source Code for Module qm.test.test_run

  1  ######################################################################## 
  2  # 
  3  # File:   test_run.py 
  4  # Author: Mark Mitchell 
  5  # Date:   2005-08-08 
  6  # 
  7  # Contents: 
  8  #   QMTest TestRun class. 
  9  # 
 10  # Copyright (c) 2005 by CodeSourcery, LLC.  All rights reserved.  
 11  # 
 12  # For license terms see the file COPYING. 
 13  # 
 14  ######################################################################## 
 15   
 16  ######################################################################## 
 17  # Imports 
 18  ######################################################################## 
 19   
 20  from qm.test.result import Result 
 21   
 22  ######################################################################## 
 23  # Classes 
 24  ######################################################################## 
 25   
26 -class TestRun(object):
27 """A 'TestRun' stores the 'Result's from a single test run. 28 29 The primary contents of a 'TestRun' are the the 'Result's of the 30 run. In addition, each 'TestRun' has an associated set of 31 annotations, which are used to store global information about the 32 'TestRun'.""" 33
34 - def GetResult(self, id, kind = Result.TEST):
35 """Return the 'Result' for the indicated test. 36 37 'id' -- The name of a test or resource. 38 39 'kind' -- The kind of result to retrieve. See 'Result' for a 40 list of the available result kinds. 41 42 returns -- The 'Result' corresponding to 'test_id'. 43 44 raises -- 'KeyError' if there is no result of the given 'kind' 45 for 'id' in the test run.""" 46 47 raise NotImplementedError
48 49
50 - def GetAnnotation(self, key):
51 """Return the annotation associated with 'key'. 52 53 'key' -- A string giving the name of an annotation. 54 55 returns -- A string giving the value of the annotation, or 56 'None' if there is no such annotation.""" 57 58 raise NotImplementedError
59 60
61 - def GetAnnotations(self):
62 """Return this run's dictionary of annotations. 63 64 returns -- A dictionary mapping annotation names (strings) to values 65 (also strings).""" 66 67 raise NotImplementedError
68 69
70 - def GetAllResults(self, directory = "", kind = Result.TEST):
71 """Return 'Result's from the given directory.. 72 73 'directory' -- A path to a directory in the test database. 74 75 'kind' -- The kind of results to return. 76 77 returns -- All the results within 'directory' (including its 78 subdirectories).""" 79 80 raise NotImplementedError
81 82
83 - def GetResultsByOutcome(self, outcome = None, directory = "", 84 kind = Result.TEST):
85 """Return 'Result's with a particular outcome. 86 87 'outcome' -- One of the 'Result.outcomes', or 'None'. 88 89 'directory' -- A path to a directory in the test database. 90 91 'kind' -- The kind of results to return. 92 93 returns -- All the results within 'directory' (including its 94 subdirectories) that have the indicated 'outcome', or, if 95 'outcome' is 'None', all test results from 'directory'.""" 96 97 results = [] 98 for result in self.GetAllResults(directory, kind): 99 # Check the outcome. 100 if outcome and result.GetOutcome() != outcome: 101 continue 102 results.append(result) 103 return results
104 105
106 - def CountOutcomes(self, directory = "", outcome = None):
107 """Return statistics about the outcomes of tests. 108 109 'directory' -- A path to a directory in the test database. 110 111 'outcome' -- If not 'None', one of the 'Result.outcomes'. 112 113 returns -- A dictionary mapping outcomes to the number of test 114 results with that outcome located within 'directory' and its 115 subdirectories. If 'outcome' is not 'None', the dictionary 116 will have an entry only for the 'outcome' specified.""" 117 118 if not outcome: 119 outcomes = Result.outcomes 120 else: 121 outcomes = (outcome,) 122 counts = {} 123 for o in outcomes: 124 counts[o] = len(self.GetResultsByOutcome(o, directory)) 125 return counts
126