def test_excinfo_getstatement(): |
def g(): |
raise ValueError |
def f(): |
g() |
try: |
f() |
except ValueError: |
-> excinfo = py.code.ExceptionInfo() |
linenumbers = [f.func_code.co_firstlineno-1+3, |
f.func_code.co_firstlineno-1+1, |
g.func_code.co_firstlineno-1+1,] |
l = list(excinfo.traceback) |
foundlinenumbers = [x.lineno for x in l] |
print l[0].frame.statement |
assert foundlinenumbers == linenumbers |