1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import qm
21 import qm.extension
22 import qm.fields
23 from qm.test.result import Result
24
25
26
27
28
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
50
51
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
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
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
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
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