Ñò
þg6Fc
@ sÌ d Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z y d d k l Z Wn# e j
o d d k l Z n Xe i
e ƒ Z d „ Z
d d „ Z d „ Z d d
d „ ƒ YZ d S( s’ Simple traceback introspection. Used to add additional information to
AssertionErrors in tests, so that failure messages may be more informative.
iÿÿÿÿN( t StringIOc
C s´ t i d | ƒ x | i o
| i } q W| i } t | ƒ \ } } t | | ƒ \ } } t t i d i | ƒ ƒ ƒ } t
| i | i ƒ } xœ | o” y t
i
| i | ƒ Wnu t
i j
of } t i d | ƒ | i d ƒ | d 8} t t i d i | ƒ ƒ ƒ } t
| i | i ƒ } q‘ n XPq‘ Wg } | i oj | i i d ƒ }
d } xO |
D]C } | | j o | i d | ƒ n | i d | ƒ | d 7} q\Wn d i | ƒ S( sÞ Inspect a traceback and its frame, returning source for the expression
where the exception was raised, with simple variable replacement performed
and the line on which the exception was raised marked with '>>'
s inspect traceback %st s Tokenizer error: %si i s
s >> s ( t logt debugt tb_nextt tb_framet tbsourcet find_inspectable_linesR t textwrapt dedentt joint Expandert f_localst f_globalst tokenizet readlinet
TokenErrort popt expanded_sourcet splitt append(
t tbt framet linest exc_linet
inspect_linest mark_linet srct expt et paddedt exp_linest ept line( ( s2 /usr/lib/python2.6/site-packages/nose/inspector.pyt inspect_traceback s@
i c C s` | i } | i } | d j o| d | d } t i d | | ƒ y t i | ƒ \ } } Wn t j
o d } } qCX| } t | d ƒ } t d t | t
| ƒ | ƒ ƒ } | | | | !} | d | } t i d j oR | d j oE xB | | d i
ƒ i d ƒ o | d 8} | | | | !} qó WqCn d } } t i d | | ƒ | | f S(
s Get source from a traceback object.
A tuple of two things is returned: a list of lines of context from
the source code, and the index of the current line within that list.
The optional second argument specifies the number of lines of context
to return, which are centered around the current line.
NOTE:
This is adapted from inspect.py in the python 2.4 standard library, since
a bug in the 2.3 version of inspect prevents it from correctly locating
source lines in a traceback frame.
i i i s lineno: %s start: %si s \s' tbsource lines '''%s''' around index %sN( i i ( t tb_linenoR R R t inspectt
findsourcet IOErrort Nonet maxt mint lent syst version_infot stript endswith( R t contextt linenoR t startR t dummyt indext all_lines( ( s2 /usr/lib/python2.6/site-packages/nose/inspector.pyR @ s,
"
c
C sž t i d ƒ } t i d ƒ } t i d ƒ } g } | | } | i | ƒ i ƒ d } | t | d d ƒ | !} | i ƒ | | d t | d t | ƒ ƒ !} x@ | D]8 }
| i |
ƒ i ƒ d | j o | i |
ƒ q¥ Pq¥ W| i ƒ | i | ƒ t | ƒ d } | i | ƒ } xg | D]_ }
| p | i |
ƒ i ƒ d | j o1 | i |
ƒ o | i |
ƒ | i |
ƒ } qPqWt
i d | | ƒ | | f S( s' Find lines in home that are inspectable.
Walk back from the err line up to 3 lines, but don't walk back over
changes in indent level.
Walk forward up to 3 lines, counting \ separated lines as 1. Don't walk
over changes in indent level (unless part of an extended line)
s
\\[\s\n]*$s :[\s\n]*$s ^(\s*)i i i i s# Inspecting lines '''%s''' around %s( t ret compilet matcht groupsR( t reverseR) R* R t searchR R (
R t post cntt dft indt toinspectt homet home_indentt beforet afterR! t home_post continued( ( s2 /usr/lib/python2.6/site-packages/nose/inspector.pyR m s6
$
'
R c B s e Z d Z d „ Z d „ Z RS( sx Simple expression expander. Uses tokenize to find the names and
expands any that can be looked up in the frame.
c C s( | | _ | | _ d | _ d | _ d S( NR ( t localst globalsR' t lposR ( t selfRF RG ( ( s2 /usr/lib/python2.6/site-packages/nose/inspector.pyt __init__™ s c C s” | i d j o6 | d | i j o" | i d | d | i 7_ n0 | d | i j o | i d | d 7_ n | d | _ | t i j o nÍ | t i j o y4 | i | } t | ƒ o
| } n
t | ƒ } Wnc t j
oW y4 | i
| } t | ƒ o
| } n
t | ƒ } Wq@t j
o
| } q@Xn X| i | 7_ n | i | 7_ t i d | | d ƒ o | i d 7_ n d S( Ni t s \s+\\\ns \
(
RH R' R R t INDENTt NAMERF t callablet reprt KeyErrorRG R5 R7 ( RI t ttypet tokR1 t endR! t val( ( s2 /usr/lib/python2.6/site-packages/nose/inspector.pyt __call__Ÿ s2 $"
( t __name__t
__module__t __doc__RJ RU ( ( ( s2 /usr/lib/python2.6/site-packages/nose/inspector.pyR • s ( ( RX R$ t loggingR5 R+ R R t cStringIOR t ImportErrort getLoggerRV R R" R R R ( ( ( s2 /usr/lib/python2.6/site-packages/nose/inspector.pyt