Package qm :: Package test :: Package classes :: Module pickle_result_stream :: Class PickleResultStream
[hide private]
[frames] | no frames]

Class PickleResultStream
source code

                 object --+            
                          |            
        extension.Extension --+        
                              |        
     result_stream.ResultStream --+    
                                  |    
file_result_stream.FileResultStream --+
                                      |
                                     PickleResultStream

A 'PickleResultStream' writes out results as Python pickles.

See also 'PickleResultReader', which does the reverse.

Nested Classes [hide private]

Inherited from extension.Extension: Type, __metaclass__


Instance Methods [hide private]
  __init__(self, arguments=None, **args)
  _ResetPickler(self)
  _WriteAnnotationPtr(self)
  WriteAnnotation(self, key, value)
Output an annotation for this run.
  WriteResult(self, result)
Output a test result.

Inherited from result_stream.ResultStream: Summarize, WriteAllAnnotations

Inherited from extension.Extension: GetClassName, GetExplicitArguments, MakeDomDocument, MakeDomElement, Write, __getattr__

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__


Class Variables [hide private]
_max_pinned_results A limit on how many `Result's to pin in memory at once.
_format_version The version number of the format we write.
arguments  
_is_binary_file If true, the file written is a binary file.
_argument_dictionary  
_argument_list  
protocol_version  

Inherited from file_result_stream.FileResultStream: file, filename

Inherited from result_stream.ResultStream: expected_outcomes, kind

Inherited from object: __class__


Method Details [hide private]

__init__(self, arguments=None, **args)
(Constructor)

source code 
Overrides: file_result_stream.FileResultStream.__init__

_ResetPickler(self)

source code 

_WriteAnnotationPtr(self)

source code 

WriteAnnotation(self, key, value)

source code 

Output an annotation for this run.

Subclasses should override this if they want to store/display annotations; the default implementation simply discards them.

'key' -- the key value as a string.

'value' -- the value of this annotation as a string.
Overrides: result_stream.ResultStream.WriteAnnotation
(inherited documentation)

WriteResult(self, result)

source code 

Output a test result.

Subclasses must override this method; the default implementation raises a 'NotImplementedError'.

'result' -- A 'Result'.
Overrides: result_stream.ResultStream.WriteResult
(inherited documentation)

Class Variable Details [hide private]

_max_pinned_results

A limit on how many `Result's to pin in memory at once.

Pickling an object normally pins it in memory; this is necessary to ensure correct behaviour when pickling multiple references to the same object. We know that `Result's can't refer to each other, so this pinning is useless overhead; however, clearing the cache at every call to `WriteResult' slows down both pickling and unpickling by about a factor of two. As a solution, any given `PickleResultStream', will clear its cache after `_max_pinned_results' calls to WriteResult. This cache-clearing technique causes a very minor slowdown on small result streams, and a substantial speedup on large result streams.
Value:
1000                                                                  
      

_format_version

The version number of the format we write.

This is bumped every time the format is changed, to make sure that we can retain backwards compatibility.

"Version 0" contains no version number, and is simply a bunch of 'Result's pickled one after another.

"Version 1", and all later versions, contain a pickled version number as the first thing in the file. In version 1, this is followed by a 4-byte unsigned integer in network byte order giving the address of the first annotation, followed by the file proper. The file proper is composed of a bunch of pickled 'Result's, followed by a pickled sentinel value (None), followed by a 4-byte unsigned integer in network-byte order, followed by the beginning of a new pickle whose first item is a annotation tuple, and following items are more 'Result's, and then another sentinel value, and so on. An annotation tuple is a tuple of n items, the first of which is a string tagging the type of annotation, and the rest of which have an interpretation that depends on the tag found. The only tag currently defined is "annotation", which is followed by two string elements giving respectively the key and the value. The 4-byte integers always point to the file address of the next such integer, except for the last, which has a value of 0; they are used to quickly find all annotations.
Value:
1                                                                     
      

arguments

Value:
[<<class 'qm.fields.IntegerField'> protocol_version>]                  
      

_is_binary_file

If true, the file written is a binary file.

This flag can be overridden by derived classes.
Value:
1                                                                     
      

_argument_dictionary

Value:
{'expected_outcomes': <<class 'qm.fields.PythonField'> expected_outcom\
es>,
 'file': <<class 'qm.fields.PythonField'> file>,
 'filename': <<class 'qm.fields.TextField'> filename>,
 'protocol_version': <<class 'qm.fields.IntegerField'> protocol_versio\
n>}                                                                    
      

_argument_list

Value:
[<<class 'qm.fields.PythonField'> expected_outcomes>,
 <<class 'qm.fields.IntegerField'> protocol_version>,
 <<class 'qm.fields.PythonField'> file>,
 <<class 'qm.fields.TextField'> filename>]                             
      

protocol_version

Value:
1