Package qm :: Package test :: Module context :: Class Context
[show private | hide private]
[frames | no frames]

Type Context

object --+    
         |    
      dict --+
             |
            Context


Test-time and local configuration for tests.

A 'Context' object contains all of the information a test needs to
execute, beyond what is stored as part of the test specification
itself.  Information in the context can include,

  * Local (per-user, etc.) configuration, such as where to find the
    tested program.

  * Environmental information, such as which machine the test is
    running on.

  * One-time configuration, including test arguments specified on
    the command line.

A 'Context' object is effectively a mapping object whose keys must
be labels and values must be strings.

Method Summary
  __init__(self, context)
Construct a new context.
  __contains__(self, key)
  __getitem__(self, key)
  get(self, key, default)
  GetAddedProperties(self)
Return the properties added to this context by resources.
  GetBoolean(self, key, default)
Return the boolean value associated with 'key'.
  GetDerivedValue(self, klass, variable, default)
Return the value for 'variable' in scope 'klass'.
  GetStringList(self, key, default)
Return the list of strings associated with 'key'.
  GetTemporaryDirectory(self)
Return the path to the a temporary directory.
  has_key(self, key)
  items(self)
  Read(self, file_name)
Read the context file 'file_name'.
    Inherited from dict
  __cmp__(x, y)
x.__cmp__(y) <==> cmp(x,y)
  __delitem__(x, y)
x.__delitem__(y) <==> del x[y]
  __eq__(x, y)
x.__eq__(y) <==> x==y
  __ge__(x, y)
x.__ge__(y) <==> x>=y
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __gt__(x, y)
x.__gt__(y) <==> x>y
  __hash__(x)
x.__hash__() <==> hash(x)
  __iter__(x)
x.__iter__() <==> iter(x)
  __le__(x, y)
x.__le__(y) <==> x<=y
  __len__(x)
x.__len__() <==> len(x)
  __lt__(x, y)
x.__lt__(y) <==> x<y
  __ne__(x, y)
x.__ne__(y) <==> x!=y
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __repr__(x)
x.__repr__() <==> repr(x)
  __setitem__(x, i, y)
x.__setitem__(i, y) <==> x[i]=y
  clear(D)
D.clear() -> None.
  copy(D)
D.copy() -> a shallow copy of D
  iteritems(D)
D.iteritems() -> an iterator over the (key, value) items of D
  iterkeys(D)
D.iterkeys() -> an iterator over the keys of D
  itervalues(D)
D.itervalues() -> an iterator over the values of D
  keys(D)
D.keys() -> list of D's keys
  pop(D, k, d)
If key is not found, d is returned if given, otherwise KeyError is raised
  popitem(D)
2-tuple; but raise KeyError if D is empty
  setdefault(D, k, d)
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
  update(...)
D.update(E, **F) -> None.
  values(D)
D.values() -> list of D's values
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)
    Inherited from type
  fromkeys(dict, S, v)
v defaults to None.

Class Variable Summary
int __safe_for_unpickling__ = 1                                                                     
str DB_PATH_CONTEXT_PROPERTY = 'qmtest.dbpath'
str ID_CONTEXT_PROPERTY = 'qmtest.id'
str TARGET_CONTEXT_PROPERTY = 'qmtest.target'
str TMPDIR_CONTEXT_PROPERTY = 'qmtest.tmpdir'

Method Details

__init__(self, context=None)
(Constructor)

Construct a new context.

'context' -- If not 'None', the existing 'Context' being wrapped by this new context.
Overrides:
__builtin__.dict.__init__

GetAddedProperties(self)

Return the properties added to this context by resources.

returns -- A map from strings to values indicating properties that were added to this context by resources.

GetBoolean(self, key, default=None)

Return the boolean value associated with 'key'.

'key' -- A string.

'default' -- A default boolean value.

returns -- The value associated with 'key' in the context, interpreted as a boolean.

If there is no value associated with 'key' and default is not 'None', then the boolean value associated with default is used. If there is no value associated with 'key' and default is 'None', an exception is raised.

The value associated with 'key' must be a string. If not, an exception is raised. If the value is a string, but does not correspond to a boolean value, an exception is raised.

GetDerivedValue(self, klass, variable, default=None)

Return the value for 'variable' in scope 'klass'.
Scopes are nested with '.', and inner variables hide
outer variables of the same name. Thus, looking up the
value of 'a.b.c.var' will return 1 if the context
contains
  a.b.c.var=1
but 2 if it contains
  a.b.d.var=1
  a.b.var=2
  a.var=3.

'klass' -- The variable's scope.

'variable' -- The variable name.

'default' -- Default value.

GetStringList(self, key, default=None)

Return the list of strings associated with 'key'.

'key' -- A string.

'default' -- A default list.

If there is no value associated with 'key' and default is not 'None', then the boolean value associated with default is used. If there is no value associated with 'key' and default is 'None', an exception is raised.

The value associated with 'key' must be a string. If not, an exception is raised. If the value is a string, but does not correspond to a string list, an exception is raised.

GetTemporaryDirectory(self)

Return the path to the a temporary directory.

returns -- The path to the a temporary directory. The 'Runnable' object may make free use of this temporary directory; no other 'Runnable's will use the same directory at the same time.

Read(self, file_name)

Read the context file 'file_name'.

'file_name' -- The name of the context file.

Reads the context file and adds the context properties in the file to 'self'.

Class Variable Details

__safe_for_unpickling__

Type:
int
Value:
1                                                                     

DB_PATH_CONTEXT_PROPERTY

Type:
str
Value:
'qmtest.dbpath'                                                        

ID_CONTEXT_PROPERTY

Type:
str
Value:
'qmtest.id'                                                            

TARGET_CONTEXT_PROPERTY

Type:
str
Value:
'qmtest.target'                                                        

TMPDIR_CONTEXT_PROPERTY

Type:
str
Value:
'qmtest.tmpdir'                                                        

Generated by Epydoc 2.1 on Thu Sep 27 15:48:59 2007 http://epydoc.sf.net