scenario.locations module¶
Execution location management.
Execution locations may be used:
to locate a class / function / method definition (see
ScenarioDefinitionandStepDefinition),to locate the place of the current execution, or where an exception occurred.
- EXECUTION_LOCATIONS¶
Main instance of
ExecutionLocations.
- class CodeLocation¶
Bases:
objectClass that describes a code location, i.e. a point where an element is defined, or the test execution takes place.
- static fromtbitem(tb_item)¶
Computes an
CodeLocationbased on a traceback item.- Parameters:
tb_item – Traceback item.
- Returns:
CodeLocationinstance.
- static frommethod(method)¶
Computes an
ExecutionLocationbased on a method.- Parameters:
method – Method to locate.
- Returns:
CodeLocationinstance.
- static fromclass(cls)¶
Computes an
ExecutionLocationbased on a class.- Parameters:
cls – Class to locate.
- Returns:
CodeLocationinstance.
- __init__(file, line, qualname)¶
Inititializes the
CodeLocationinstance with the given values.- Parameters:
file – File path where the execution takes place.
line – Line in the file where the execution takes place.
qualname – Qualified name of the class/function pointed.
- file¶
File path.
Set as a
Pathwhenfileis passed on as aPath. Set as apathlib.Pathotherwise, possibly a relative path in that case.
- line¶
Line number in the file.
- qualname¶
Method name.
- __eq__(other)¶
Compares the
CodeLocationinstance with another object.- Parameters:
other – Candidate object.
- Returns:
Trueif the objects are similar,Falseotherwise.
- tolongstring()¶
Long text representation.
- static fromlongstring(long_string)¶
Computes an
ExecutionLocationfrom its long text representation.- Parameters:
long_string – Long text, as returned by
tolongstring().- Returns:
CodeLocationinstance.
- class ExecutionLocations¶
Bases:
LoggerMethods to build execution location stacks.
- __init__()¶
Sets up logging for the
ExecutionLocationsclass.
- fromcurrentstack(limit=None, fqn=False)¶
Builds a stack of
CodeLocationfrom the current call stack.- Parameters:
limit – Maximum number of backward items.
fqn –
Trueto ensure fully qualified names.
- Returns:
Stack of
CodeLocation.
- fromexception(exception, limit=None, fqn=False)¶
Builds a stack of
CodeLocationfrom an exception.- Parameters:
exception – Exception to build the stack from.
limit – Maximum number of backward items.
fqn –
Trueto ensure fully qualified names.
- Returns:
Stack of
CodeLocation.
- _fromtbitems(tb_items, limit=None, fqn=False)¶
Builds a stack of
CodeLocationfrom traceback items.- Parameters:
tb_items – Traceback items to build the stack from.
- Returns:
Stack of
CodeLocation.