scenario.locations module¶
Execution location management.
Execution locations may be used:
to locate a class / function / method definition (see
ScenarioDefinition
andStepDefinition
),to locate the place of the current execution, or where an exception occurred.
- EXECUTION_LOCATIONS¶
Main instance of
ExecutionLocations
.
- class CodeLocation¶
Bases:
object
Class 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
CodeLocation
based on a traceback item.- Parameters:
tb_item – Traceback item.
- Returns:
CodeLocation
instance.
- static frommethod(method)¶
Computes an
ExecutionLocation
based on a method.- Parameters:
method – Method to locate.
- Returns:
CodeLocation
instance.
- static fromclass(cls)¶
Computes an
ExecutionLocation
based on a class.- Parameters:
cls – Class to locate.
- Returns:
CodeLocation
instance.
- __init__(file, line, qualname)¶
Inititializes the
CodeLocation
instance 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
Path
whenfile
is passed on as aPath
. Set as apathlib.Path
otherwise, possibly a relative path in that case.
- line¶
Line number in the file.
- qualname¶
Method name.
- __eq__(other)¶
Compares the
CodeLocation
instance with another object.- Parameters:
other – Candidate object.
- Returns:
True
if the objects are similar,False
otherwise.
- tolongstring()¶
Long text representation.
- static fromlongstring(long_string)¶
Computes an
ExecutionLocation
from its long text representation.- Parameters:
long_string – Long text, as returned by
tolongstring()
.- Returns:
CodeLocation
instance.
- class ExecutionLocations¶
Bases:
Logger
Methods to build execution location stacks.
- __init__()¶
Sets up logging for the
ExecutionLocations
class.
- fromcurrentstack(limit=None, fqn=False)¶
Builds a stack of
CodeLocation
from the current call stack.- Parameters:
limit – Maximum number of backward items.
fqn –
True
to ensure fully qualified names.
- Returns:
Stack of
CodeLocation
.
- fromexception(exception, limit=None, fqn=False)¶
Builds a stack of
CodeLocation
from an exception.- Parameters:
exception – Exception to build the stack from.
limit – Maximum number of backward items.
fqn –
True
to ensure fully qualified names.
- Returns:
Stack of
CodeLocation
.
- _fromtbitems(tb_items, limit=None, fqn=False)¶
Builds a stack of
CodeLocation
from traceback items.- Parameters:
tb_items – Traceback items to build the stack from.
- Returns:
Stack of
CodeLocation
.