Testing and Diagnostics Modules

trace

Tracks execution of Python statements and calls. Trace can collect line counts or display execution events for trusted code. Counts indicate which lines ran, not whether all branches or correctness properties were tested. Instrumentation affects performance.

Formal Syntax & Structure

python syntaxpython
import trace

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
from trace import Trace
def total():    return sum([1, 2, 3])
tracer = Trace(count=1, trace=0)print(tracer.runfunc(total))
Python Reference