Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/nose/inspector.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�9�c@s�dZddlZddlZddlZddlZddlZddlZyddlmZWn!e	k
r�ddlmZnXej
e�Zd�Z
dd�Zd�Zdd
d	��YZdS(s�Simple traceback introspection. Used to add additional information to
AssertionErrors in tests, so that failure messages may be more informative.
i�N(tStringIOcCs�tjd|�x|jr(|j}qW|j}t|�\}}t||�\}}ttjdj	|���}t
|j|j�}x�|r:y+x$t
j|j�D]}||�q�WWnst
jk
r5}	tjd|	�|jd�|d8}ttjdj	|���}t
|j|j�}q�nXPq�Wg}
|jr�|jjd�}d}xL|D]A}
||kr�|
jd|
�n|
jd|
�|d7}qiWndj	|
�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 '>>'
    sinspect traceback %stsTokenizer error: %siis
s>>  s    (tlogtdebugttb_nextttb_framettbsourcetfind_inspectable_linesRttextwraptdedenttjointExpandertf_localst	f_globalsttokenizetgenerate_tokenstreadlinet
TokenErrortpoptexpanded_sourcetsplittappend(ttbtframetlinestexc_linet
inspect_linest	mark_linetsrctexpttoktetpaddedt	exp_linesteptline((s2/sys/lib/python2.7/site-packages/nose/inspector.pytinspect_tracebacks<
		

	
ic	Csc|j}|j}|dkr6|d|d}tjd||�ytj|�\}}Wn!tk
rdgd}}qFX|}t|d�}tdt|t	|�|��}||||!}|d|}t
jd	krF|dkrFx?||dj�j
d�r/|d8}||||!}q�Fndgd}}tjd||�||fS(
sGet 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.
    iiislineno: %s start: %sRis\s'tbsource lines '''%s''' around index %s(ii(t	tb_linenoRRRtinspectt
findsourcetIOErrortmaxtmintlentsystversion_infotstriptendswith(	RtcontexttlinenoRtstartRtdummytindext	all_lines((s2/sys/lib/python2.7/site-packages/nose/inspector.pyRAs*		
" 
c
Cs�tjd�}tjd�}tjd�}g}||}|j|�j�d}|t|dd�|!}|j�||dt|dt|��!}	x>|D]6}
|j|
�j�d|kr�|j|
�q�Pq�W|j�|j|�t|�d}|j	|�}xc|	D][}
|sG|j|
�j�d|krv|j	|
�rv|j|
�|j	|
�}qPqWt
jd||�||fS(	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*)iiiis#Inspecting lines '''%s''' around %s(tretcompiletmatchtgroupsR)treverseR*R+RtsearchRR(
Rtpostcnttdftindt	toinspectthomethome_indenttbeforetafterR#thome_post	continued((s2/sys/lib/python2.7/site-packages/nose/inspector.pyRms2	

$



%
RcBs eZdZd�Zd�ZRS(sxSimple expression expander. Uses tokenize to find the names and
    expands any that can be looked up in the frame.
    cCs(||_||_d|_d|_dS(NR(tlocalstglobalstNonetlposR(tselfRGRH((s2/sys/lib/python2.7/site-packages/nose/inspector.pyt__init__�s			cCs�|jdk	rs|d|jkrC|jd|d|j7_qs|d|jkrs|jd|d7_qsn|d|_|tjkr�n�|tjkrEy2|j|}t|�r�|}nt|�}Wn]t	k
r2y2|j
|}t|�r|}nt|�}Wq3t	k
r.|}q3XnX|j|7_n|j|7_tjd||d�r�|jd7_ndS(Nit s\s+\\\ns \
(
RJRIRRtINDENTtNAMERGtcallabletreprtKeyErrorRHR6R8(RKtttypeRR2tendR#tval((s2/sys/lib/python2.7/site-packages/nose/inspector.pyt__call__�s4!

	

	
(t__name__t
__module__t__doc__RLRV(((s2/sys/lib/python2.7/site-packages/nose/inspector.pyR�s	((RYR&tloggingR6R,RRt	cStringIORtImportErrort	getLoggerRWRR$RRR(((s2/sys/lib/python2.7/site-packages/nose/inspector.pyt<module>s
	/,	(

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.