Python supports registering a function for profiling purposes. Using this mechanism it is possible to add command tracing and "per-command" screenshots to Python test scripts.
An example implementation (called "squish_trace") can be downloaded here .
Here is an example test script that makes use of the squish_trace functionality:
from squish_trace import *
def main():
# Enable trace, 500 ms delay in between commands:
squish_trace_enable(1000)
# Enable trace, 500 ms delay in between commands,
# enable screenshots, using saveDesktopScreenshot():
#squish_trace_enable(command_delay_in_milliseconds=500, take_screenshots=True)
# Enable trace, 500 ms delay in between commands,
# enable screenshots, use external tool "take_screenshot"
# for taking screenshots:
#squish_trace_set_screenshot_external_command('take_screenshot "%s"')
#squish_trace_enable(command_delay_in_milliseconds=500, take_screenshots=True)
for i in range(3):
test.log("Iteration #%s" % (i+1))
The additional log entries generated by squish_trace:

Note:
Lines with
>>
denote entering a functionLines with
<<
denote exiting a function.The tooltip of each trace log entry shows the local variables and their values at that point in time, in the above example the variable "i" of the for loop.
Related information and resources:
Windows command line screenshot tool (captures mouse cursor, too): take_screenshot