summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2009-01-22 11:10:33 +0100
committerAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2009-01-22 11:10:33 +0100
commita2a8f9a110799fc3f2900850c0e64a4015e15f70 (patch)
tree3381b561454690a9010a01ab590ec55232cd1d15
parent7690afc3825e2582934421850d20a922d9370b9a (diff)
downloadlogilab-common-a2a8f9a110799fc3f2900850c0e64a4015e15f70.tar.gz
[testlib] fix bug in traceback formatting: handle cases where we source code is not available
-rw-r--r--testlib.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/testlib.py b/testlib.py
index 15d2df3..55c809b 100644
--- a/testlib.py
+++ b/testlib.py
@@ -392,7 +392,10 @@ class SkipAwareTestResult(unittest._TextTestResult):
if not (0 < index <= nb_frames_skipped):
continue
filename = osp.abspath(filename)
- source = ''.join(ctx)
+ if ctx is None: # pyc files or C extensions for instance
+ source = '<no source available>'
+ else:
+ source = ''.join(ctx)
if colorize:
filename = textutils.colorize_ansi(filename, 'magenta')
source = colorize_source(source)