Package qm :: Package test :: Package classes :: Module file :: Class FileContentsTest
[hide private]
[frames] | no frames]

Class FileContentsTest
source code

         object --+            
                  |            
extension.Extension --+        
                      |        
      runnable.Runnable --+    
                          |    
                  test.Test --+
                              |
                             FileContentsTest

Check that the contents of a file match the expected value.

A 'FileContentsTest' examines the contents of a file. The test passes if and only if the contents exactly match the expected value.

The path to the file itself is not specified explicitly in the test. Instead, it is taken from a contex property; the name of that variable is specified in the **Path Property** field.

Optionally, the test may specify one or more substitutions. Each substitution consists of a regular expression pattern and a replacement string. Both the actual file contents and the expected file contents are processed with these substitutions, with all pattern matches replaced with the corresponding substitutions, before the comparison is performed.

Nested Classes [hide private]

Inherited from test.Test: OutcomeField, TestField

Inherited from runnable.Runnable: ResourceField

Inherited from extension.Extension: Type, __metaclass__


Instance Methods [hide private]
  Run(self, context, result)
Run the test.
  __PerformSubstitutions(self, text)
Perform substitutions on a body of text.

Inherited from test.Test: GetTargetGroup

Inherited from runnable.Runnable: GetAttachments, GetDatabase, GetId, __init__

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]
arguments  
_argument_dictionary  
_argument_list  
expected_contents  
path_property  
substitutions  

Inherited from test.Test: PREREQUISITES_FIELD_ID, kind, prerequisites, target_group

Inherited from runnable.Runnable: EXTRA_DATABASE, EXTRA_ID, RESOURCE_FIELD_ID, resources

Inherited from object: __class__


Method Details [hide private]

Run(self, context, result)

source code 

Run the test.

'context' -- A 'Context' giving run-time parameters to the test.

'result' -- A 'Result' object. The outcome will be 'Result.PASS' when this method is called. The 'result' may be modified by this method to indicate outcomes other than 'Result.PASS' or to add annotations.

This method should not return a value.

Derived classes must override this method.
Overrides: test.Test.Run
(inherited documentation)

__PerformSubstitutions(self, text)

source code 

Perform substitutions on a body of text.

returns -- The string 'text', processed with the substitutions configured for this test instance.

Class Variable Details [hide private]

arguments

Value:
[<<class 'qm.fields.TextField'> path_property>,
 <<class 'qm.fields.TextField'> expected_contents>,
 <<class 'qm.fields.SetField'> substitutions>]                         
      

_argument_dictionary

Value:
{'expected_contents': <<class 'qm.fields.TextField'> expected_contents\
>,
 'path_property': <<class 'qm.fields.TextField'> path_property>,
 'prerequisites': <<class 'qm.fields.SetField'> prerequisites>,
 'resources': <<class 'qm.fields.SetField'> resources>,
 'substitutions': <<class 'qm.fields.SetField'> substitutions>,
 'target_group': <<class 'qm.test.test.TargetGroupField'> target_group\
>}                                                                     
      

_argument_list

Value:
[<<class 'qm.fields.SetField'> prerequisites>,
 <<class 'qm.test.test.TargetGroupField'> target_group>,
 <<class 'qm.fields.SetField'> substitutions>,
 <<class 'qm.fields.TextField'> path_property>,
 <<class 'qm.fields.TextField'> expected_contents>,
 <<class 'qm.fields.SetField'> resources>]                             
      

expected_contents

Value:
''                                                                     
      

path_property

Value:
'path'                                                                 
      

substitutions

Value:
[]