Package epyunit :: Module SubprocUnit :: Class SProcUnitRules
[hide private]
[frames] | no frames]

Class SProcUnitRules

source code


The 'epyunit.SubprocUnit.SProcUnitRules' defines the expected data, and the minimal degree of expectation. Therefore a set of parameters constitute a basic rule set, which matches the provided reference data on the actual response data.
Instance Methods [hide private]
 
__init__(self, **kargs)
Initializes the ruleset and operational parameters.
source code
 
reset(self)
A completely empty initial in-place default set for current variables.
source code
 
setkargs(self, **kargs)
Sets supported parameters.
source code
 
setrules(self, **predef)
Initialize and reset parameters and previous results.
source code
 
apply(self, ret)
Apply rules on the input ret and weight the result.
source code
 
states(self)
State values of current applied unittest.
source code
 
__str__(self)
Prints current rule set.
source code
 
_re_pattern(self, pat) source code
 
__repr__(self)
Represents current rule set.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Variables [hide private]
  rules_default = {'_exitcond': False, '_exitret': 0, 'cflags': ...
The default rules for OK operations.
Instance Variables [hide private]
  stderrok
list of 're' patterns indicating success on STDERR
  stdoutnok
list of 're' patterns indicating success on STDOUT
  stdoutok
list of 're' patterns indicating success on STDOUT
  stdoutnok_matched
list of actually matched failure strings on STDOUT
  stdoutok_matched
list of actually matched success strings on STDOUT
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **kargs)
(Constructor)

source code 

Initializes the ruleset and operational parameters.

For parameters refer to called setrules and setkargs.

Overrides: object.__init__

setkargs(self, **kargs)

source code 

Sets supported parameters.

Applicable for the initial call of self.__init__(), and later modification.

Tolerates unknown keyword parameters, pops own.

Args:

**kargs: Parameter specific for the operation,

debug: Sets debug for rule application.

verbose: Sets verbose for rule application.

Returns:
When successful returns 'True', else returns either 'False', or raises an exception.
Raises:
passed through exceptions:

setrules(self, **predef)

source code 

Initialize and reset parameters and previous results.

Args:

**kargs:

setdefault: Sets the predefined default dictionary,
see 'rules_default'.

debug:

True: see re.DEBUG, when set

False: default:=unset

dotall:

True: see re.DOTALL, when set

False: default:=unset

exitign:

True: Ignores exit at all.

False: Does not ignore exit value.

exittype:

False|'nok': Success when exit is not 0.

True|'ok': Success when exit is 0.

'value': Success when exit is equal <exit-value>.

exitval=<exit-value>: A specific exit value indicating
success.

ignorecase:

True: see re.IGNORECASE, when set

False: default:=unset

multiline:

True: see re.MULTILINE, when set

False: default:=unset

priotype:

False|'nok': One failure state sets the whole case
to failure. This is the default.
True|'ok': One success state sets the whole case
to success.

weight: Choose larger values of counters.

<customcallback>: Custom callback with signature:

customcallback(self,ret)

self: Current instance.

ret: Data provided to apply.

reset: A reset dictionary, see 'rules_reset'.

result: Required sum of all matches for success,
else failure.
resultnok: Required sum of NOK matches for failure,
else success.
resultok: Required sum of OK matches for success,
else failure.
stderrnok: List of regular expressions for match on

STDERR, indicating failure.

Could contain app-cached precompiled 're'.

stderrok: List of regular expressions for match on

STDERR, indicating success.

Could contain app-cached precompiled 're'.

stdoutnok: List of regular expressions for match on

STDOUT, indicating failure.

Could contain app-cached precompiled 're'.

stdoutok: List of regular expressions for match on

STDOUT, indicating success.

Could contain app-cached precompiled 're'.

unicode:

True: see re.UNICODE, when set

False: default:=unset

Returns:
When successful returns 'True', else returns either 'False', or raises an exception.
Raises:
passed through exceptions:

apply(self, ret)

source code 

Apply rules on the input ret and weight the result.

The provided match patterns and values are matched onto the input, and the number of matches is counted.

The number of required matches of sub-patterns has to be defined within the regexpr, e.g. by:

'abv{4}[^v]+'

this matches on:

abvvvv
Args:
ret: Tuple received from 'SystemCalls'.
Returns:
When successful returns 'True', else returns either 'False', or raises an exception.
Raises:
passed through exceptions:

states(self)

source code 

State values of current applied unittest.

The applied parameters are available by 'repr()'.

Args:
ret: Tuple received from 'SystemCalls'.
Returns:

Returns the state of the last 'apply' operation. this is the result of the 'filter' and 'countres' described in the manual by the syntax-tree:

r = {
  '_exitcond' = self._exitcond,   # resulting after applied self.exittype
  'exit' = self._exitret, # see _exitcond
  'stderrnok' = self.stderrnok_matched,
  'stderrok' = self.stderrok_matched,
  'stdoutnok' = self.stdoutnok_matched,
  'stdoutok' = self.stdoutok_matched,

  'result' = self.result_cnt,
  'resultnok' = self.resultnok_cnt,
  'resultok' = self.resultok_cnt,
}
Raises:
passed through exceptions:

__str__(self)
(Informal representation operator)

source code 
Prints current rule set.
Overrides: object.__str__

__repr__(self)
(Representation operator)

source code 
Represents current rule set.
Overrides: object.__repr__

Class Variable Details [hide private]

rules_default

The default rules for OK operations.
Value:
{'_exitcond': False,
 '_exitret': 0,
 'cflags': 0,
 'debug': 0,
 'default': True,
 'dotall': 0,
 'exitign': False,
 'exittype': 8,
...