Before passing exceptions on up, inject context information into them which can later be used by __str__(). Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx> --- client/common_lib/test.py | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/client/common_lib/test.py b/client/common_lib/test.py index 2561242..9521326 100644 --- a/client/common_lib/test.py +++ b/client/common_lib/test.py @@ -596,13 +596,17 @@ def _call_test_function(func, *args, **dargs): inside test code are considered test failures.""" try: return func(*args, **dargs) - except error.AutotestError: - # Pass already-categorized errors on up as is. - raise + except error.AutotestError, e: + # Inject context info and pass already-categorized errors on up. + e.context = error.get_context(sys.exc_info()[2]) + raise sys.exc_info()[0], e, sys.exc_info()[2] except Exception, e: - # Other exceptions must be treated as a FAIL when - # raised during the test functions - raise error.UnhandledTestFail(e) + # Other exceptions are treated as a FAIL when raised during the test + # functions. Convert them to UnhandledTestFail, inject context info + # and pass them on up. + e = error.UnhandledTestFail(e) + e.context = error.get_context(sys.exc_info()[2]) + raise e def runtest(job, url, tag, args, dargs, -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html