import traceback
def main():
func1()
def func1():
func2()
def func2():
log_backtrace()
if not test.verify(False, "message"):
log_backtrace()
def log_backtrace():
backtrace_frames = traceback.extract_stack()
filename, line_number, function, code = backtrace_frames[0]
msg = "Backtrace: %s:%s: %s()\n" % (filename, line_number, function)
detail = ""
for frame in backtrace_frames[:-1]:
filename, line_number, function, code = frame
detail += "%s:%s: %s()\n" % (filename, line_number, function)
test.log(msg, detail)