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

Source Code for Module qm.test.result_stream

  1  ######################################################################## 
  2  # 
  3  # File:   result_stream.py 
  4  # Author: Mark Mitchell 
  5  # Date:   2001-10-10 
  6  # 
  7  # Contents: 
  8  #   QMTest ResultStream class. 
  9  # 
 10  # Copyright (c) 2001, 2002, 2003 by CodeSourcery, LLC.  All rights reserved.  
 11  # 
 12  # For license terms see the file COPYING. 
 13  # 
 14  ######################################################################## 
 15   
 16  ######################################################################## 
 17  # imports 
 18  ######################################################################## 
 19   
 20  import qm 
 21  import qm.extension 
 22  import qm.fields 
 23  from   qm.test.result import Result 
 24   
 25  ######################################################################## 
 26  # classes 
 27  ######################################################################## 
 28   
29 -class ResultStream(qm.extension.Extension):
30 """A 'ResultStream' displays test results. 31 32 A 'ResultStream' is responsible for displaying test results for 33 the user as they arrive. It may also display summary information 34 when the results are complete. The 'ResultStream' may also 35 choose to write the results to a file for permanent storage. 36 37 'ResultStream' is an abstract class. 38 39 """ 40 41 kind = "result_stream" 42 43 expected_outcomes = qm.fields.PythonField() 44 45
46 - def __init__(self, arguments = None, **args):
47 48 if arguments: args.update(arguments) 49 super(ResultStream, self).__init__(**args)
50 51
52 - def WriteAnnotation(self, key, value):
53 """Output an annotation for this run. 54 55 Subclasses should override this if they want to store/display 56 annotations; the default implementation simply discards them. 57 58 'key' -- the key value as a string. 59 60 'value' -- the value of this annotation as a string.""" 61 62 pass
63 64
65 - def WriteAllAnnotations(self, annotations):
66 """Output all annotations in 'annotations' to this stream. 67 68 Currently this is the same as making repeated calls to 69 'WriteAnnotation', but in the future, as special annotation 70 types like timestamps are added, this will do the work of 71 dispatching to functions like 'WriteTimestamp'. 72 73 Should not be overridden by subclasses.""" 74 75 for key, value in annotations.iteritems(): 76 self.WriteAnnotation(key, value)
77 78
79 - def WriteResult(self, result):
80 """Output a test result. 81 82 Subclasses must override this method; the default 83 implementation raises a 'NotImplementedError'. 84 85 'result' -- A 'Result'.""" 86 87 raise NotImplementedError
88 89
90 - def Summarize(self):
91 """Output summary information about the results. 92 93 When this method is called, the test run is complete. Summary 94 information should be displayed for the user, if appropriate. 95 Any finalization, such as the closing of open files, should 96 also be performed at this point. 97 98 Derived class methods may override this method. They should, 99 however, invoke this version before returning.""" 100 101 pass
102 103
104 - def _GetExpectedOutcome(self, test_id):
105 """Return the outcome expected for 'test_id'. 106 107 returns -- The outcome (one of the elements of 108 'Result.outcomes') expected for 'test_id'. The expected 109 outcome is taken from the 'expected_outcomes' provided when 110 constructing this result stream, if available. If no expected 111 outcome is available the default value ('Result.PASS') will be 112 returned.""" 113 114 return self.expected_outcomes.get(test_id, Result.PASS)
115