
i\c           @` s  d  d l  m Z d  d l  m Z d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m	 Z	 d  d l
 m Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l Z d  d	 l m Z d  d
 l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z e rId  d l m Z n d d l m Z d e f d     YZ d e f d     YZ d e f d     YZ d e  f d     YZ! e" d d d  Z# e j$ d e%  d e f d     Y Z& e j$ d e f d      Y Z' d! e f d"     YZ( d# e( f d$     YZ) d% e) f d&     YZ* d' e) f d(     YZ+ d) e( f d*     YZ, d+ e, f d,     YZ- d- e( f d.     YZ. d/ e( f d0     YZ/ d1 e( f d2     YZ0 d3 e( f d4     YZ1 d5 e( f d6     YZ2 e3 d7  Z4 e rd8   Z5 n	 d9   Z5 e j6 j7 e j8 j9 d:   Z: e: j; d; k r_e: j<   Z: n  e j6 j7 e j8  j<   Z= e j6 j7 e j8  j<   Z> d<   Z? d S(=   i    (   t   absolute_import(   t   division(   t   print_functionN(   t
   CO_VARARGS(   t   CO_VARKEYWORDS(   t   ref(   t	   text_type(   t
   safeformat(   t   saferepr(   t   _PY2(   t   _PY3(   t   PY35(   t   safe_str(   t   format_exception_onlyi   t   Codec           B` sb   e  Z d  Z d   Z d   Z d Z d   Z e d    Z	 e d    Z
 d   Z e d  Z RS(	   s$    wrapper around Python code objects c         C` s~   t  | d  s t |  } n  y, | j |  _ | j d |  _ | j |  _ Wn$ t k
 rp t	 d | f   n X| |  _
 d  S(   Nt   co_filenamei   s   not a code object: %r(   t   hasattrt
   getrawcodeR   t   filenamet   co_firstlinenot   firstlinenot   co_namet   namet   AttributeErrort	   TypeErrort   raw(   t   selft   rawcode(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   __init__$   s    c         C` s   |  j  | j  k S(   N(   R   (   R   t   other(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   __eq__/   s    c         C` s   |  | k S(   N(    (   R   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   __ne__4   s    c         C` s[   y7 t  j j |  j j  } | j   s6 t d   n  Wn t k
 rV |  j j } n X| S(   ss    return a path object pointing to source code (note that it
        might not point to an actually existing file). s   py.path check failed.(   t   pyt   patht   localR   R   t   checkt   OSError(   R   t   p(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR!   7   s    c         C` s,   d d l  m } | j |  j  \ } } | S(   sS    return a _pytest._code.Source object for the full source file of the code
        i    (   t   source(   t   _pytest._codeR&   t
   findsourceR   (   R   R&   t   fullt   _(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt
   fullsourceG   s    c         C` s   d d l  } | j j |  j  S(   sP    return a _pytest._code.Source object for the code object's source only
        i    N(   R'   t   _codet   SourceR   (   R   t   _pytest(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR&   P   s    c         C` sH   |  j  } | j } | r= | | j t @7} | | j t @7} n  | j |  S(   s    return a tuple with the argument names for the code object

            if 'var' is set True also return the names of the variable and
            keyword arguments when present
        (   R   t   co_argcountt   co_flagsR   R   t   co_varnames(   R   t   varR   t   argcount(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   getargsX   s    		N(   t   __name__t
   __module__t   __doc__R   R   t   Nonet   __hash__R   t   propertyR!   R+   R&   t   FalseR4   (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR   !   s   					t   Framec           B` sV   e  Z d  Z d   Z e d    Z d   Z d   Z d   Z d   Z	 e
 d  Z RS(   sg   Wrapper around a Python frame holding f_locals and f_globals
    in which expressions can be evaluated.c         C` sG   | j  d |  _ | j |  _ | j |  _ | |  _ t | j  |  _ d  S(   Ni   (   t   f_linenot   linenot	   f_globalst   f_localsR   R   t   f_codet   code(   R   t   frame(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR   k   s
    	c         C` sD   d d l  } |  j j d k r. | j j d  S|  j j j |  j  S(   s    statement this frame is at i    Nt    (   R'   RB   R+   R8   R,   R-   t   getstatementR>   (   R   R.   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt	   statementr   s    c         K` s/   |  j  j   } | j |  t | |  j |  S(   s    evaluate 'code' in the frame

            'vars' are optional additional local variables

            returns the result of the evaluation
        (   R@   t   copyt   updatet   evalR?   (   R   RB   t   varsR@   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyRI   {   s    c         J` s-   |  j  j   } | j |  | |  j | Ud S(   s^    exec 'code' in the frame

            'vars' are optiona; additional local variables
        N(   R@   RG   RH   R?   (   R   RB   RJ   R@   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   exec_   s    c         C` s
   t  |  S(   sL    return a 'safe' (non-recursive, one-line) string repr for 'object'
        (   R   (   R   t   object(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   repr   s    c         C` s   | S(   N(    (   R   RL   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   is_true   s    c         C` sY   g  } xL |  j  j |  D]8 } y | j | |  j | f  Wq t k
 rP q Xq W| S(   s    return a list of tuples (name, value) for all arguments

            if 'var' is set True also include the variable and keyword
            arguments when present
        (   RB   R4   t   appendR@   t   KeyError(   R   R2   t   retvalt   arg(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR4      s    (   R5   R6   R7   R   R:   RF   RI   RK   RM   RN   R;   R4   (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR<   g   s   							t   TracebackEntryc           B` s   e  Z d  Z d Z d Z d d  Z d   Z e d    Z	 e d    Z
 d   Z e d    Z e d    Z d   Z e e d d d	  Z d
   Z d d  Z e e  Z d   Z d   Z d   Z e e d d d  Z RS(   s    a single entry in a traceback c         C` s&   | |  _  | |  _ | j d |  _ d  S(   Ni   (   t   _excinfot	   _rawentryt	   tb_linenoR>   (   R   t   rawentryt   excinfo(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR      s    		c         C` s   | d k s t   | |  _ d  S(   Nt   shortt   long(   RY   RZ   (   t   AssertionErrort   _repr_style(   R   t   mode(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   set_repr_style   s    c         C` s"   d d  l  } | j j |  j j  S(   Ni    (   R'   R,   R<   RU   t   tb_frame(   R   R.   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyRC      s    c         C` s   |  j  |  j j j S(   N(   R>   RC   RB   R   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   relline   s    c         C` s   d |  j  j j |  j d f S(   Ns   <TracebackEntry %s:%d>i   (   RC   RB   R!   R>   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   __repr__   s    c         C` s   |  j  j j } | j |  j  S(   s7    _pytest._code.Source object for the current statement (   RC   RB   R+   RE   R>   (   R   R&   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyRF      s    c         C` s   |  j  j j S(   s    path to the source code (   RC   RB   R!   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR!      s    c         C` s
   |  j  j S(   N(   RC   R@   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt	   getlocals   s    s   locals of underlaying framec         C` s   t  |  j j j d  S(   Ni    (   t   maxRC   RB   R   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   getfirstlinesource   s    c   	      C` s   d d l  m } |  j j j } | d k r/ d Sd } } | d k	 rx |  j j j } | d k	 rx | j | d  } qx n  |  j   } y% | |  j	 | d | \ } } } Wn t
 k
 r |  j	 d } n X| d k	 r | | | <n  | | | !S(   s    return failing source code. i    (   t   getstatementrange_astt   astnodei   N(   t   _pytest._code.sourceRe   RC   RB   R+   R8   R!   t   getRd   R>   t   SyntaxError(	   R   t   astcacheRe   R&   t   keyRf   t   startR*   t   end(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt	   getsource   s$    
"c         C` sh   |  j  } | j j d | j j d t   } | rd t |  rd | |  j d k rW d n	 |  j    S| S(   s$   return True if the current frame has a var __tracebackhide__
            resolving to True.

            If __tracebackhide__ is a callable, it gets called with the
            ExceptionInfo instance and can decide whether to hide the traceback.

            mostly for internal use
        t   __tracebackhide__N(   RC   R@   Rh   R?   R;   t   callableRT   R8   (   R   t   ft   tbh(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   ishidden   s    			%c         C` s   y t  |  j  } Wn t j j k
 r2 d } n X|  j j j } y t  |  j  j	   } Wn  t
 k
 rq   n d } n Xd | |  j d | | f S(   Ns   ???s     File %r:%d in %s
  %s
i   (   t   strR!   R    t   errort   ErrorRC   RB   R   RF   t   lstript   KeyboardInterruptR>   (   R   t   fnR   t   line(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   __str__  s    

c         C` s   |  j  j j j S(   N(   RC   RB   R   R   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s    s   co_name of underlaying codeN(   R5   R6   R7   R8   R\   t   exprinfoR   R^   R:   RC   R`   Ra   RF   R!   Rb   t   localsRd   Rn   R&   Rs   R{   R   (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyRS      s&   							t	   Tracebackc           B` s_   e  Z d  Z e Z d d  Z d d d d d  Z d   Z d   d  Z	 d   Z
 d   Z RS(	   s_    Traceback objects encapsulate and offer higher level
        access to Traceback entries.
    c         ` sW      _  t | d  rC    f d   } t j  | |   n t j  |  d S(   sA    initialize from given python traceback object and ExceptionInfo t   tb_nextc         3` s4   x- |  d  k	 r/  j |  d   V|  j }  q Wd  S(   NRX   (   R8   t   EntryR   (   t   cur(   RX   R   (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyRq   #  s    N(   RT   R   t   listR   (   R   t   tbRX   Rq   (    (   RX   R   s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s
    	c         C` s   x |  D] } | j  j } | j } | d k s: | | k r | d k sf t | d  sf | j |  r | d k s | j | k r | d k s | j  j j | k r t | j	 |  j
  Sq W|  S(   s   return a Traceback instance wrapping part of this Traceback

            by provding any combination of path, lineno and firstlineno, the
            first frame to start the to-be-returned traceback is determined

            this allows cutting the first part of a Traceback instance e.g.
            for formatting reasons (removing some uninteresting bits that deal
            with handling of the exception/traceback)
        t   reltoN(   RC   RB   R!   R8   R   R   R>   R   R~   RU   RT   (   R   R!   R>   R   t   excludepatht   xRB   t   codepath(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   cut,  s    
	!c         C` sI   t  t |   j |  } t | t t d    rE |  j |  } n  | S(   Ni    (   t   superR~   t   __getitem__t
   isinstancet   typet   slicet	   __class__(   R   Rk   t   val(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR   F  s    c         C` s   |  j    S(   N(   Rs   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   <lambda>L  RD   c         C` s   t  t | |   |  j  S(   sv   return a Traceback instance with certain items removed

            fn is a function that gets a single argument, a TracebackEntry
            instance, and should return True when the item should be added
            to the Traceback, False when not

            by default this removes all the TracebackEntries which are hidden
            (see ishidden() above)
        (   R~   t   filterRT   (   R   Ry   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR   L  s    
c         C` sJ   x? t  d t |   d d  D]  } |  | } | j   s | Sq W|  d S(   sc    return last non-hidden traceback entry that lead
        to the exception of a traceback.
        ii   (   t   ranget   lenRs   (   R   t   it   entry(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   getcrashentryX  s
    $
c   	   	   C` s   i  } x t  |   D] \ } } | j j j t | j j j  | j f } | j | g   } | r | j } | j } x9 | D]. } | j	 | j
 t d | d |  rz | Sqz Wn  | j | j j  q Wd S(   s    return the index of the frame/TracebackEntry where recursion
            originates if appropriate, None if no recursion occurred
        t   __recursioncache_locals_1t   __recursioncache_locals_2N(   t	   enumerateRC   RB   R!   t   idR   R>   t
   setdefaultR@   RN   RI   t   co_equalRO   R8   (	   R   t   cacheR   R   Rk   t   valuesRq   t   loct   otherloc(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   recursionindexb  s     *		N(   R5   R6   R7   RS   R   R8   R   R   R   R   R   R   (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR~     s   		
s6   __recursioncache_locals_1 == __recursioncache_locals_2t   ?RI   RM   t   ExceptionInfoc           B` s.  e  Z d  Z e r d n d Z e j   Z e j d d  Z e j d d  Z
 e d d   Z e d    Z e d    Z e d    Z e d	    Z e d
    Z e d    Z e j d    Z d   Z e d  Z d   Z d   Z e d e e e e e d  Z d   Z d   Z d   Z RS(   sX    wraps sys.exc_info() objects and offers
        help for navigating the traceback.
    s   AssertionError(u'assert s   AssertionError('assert t   defaultRD   c         C` s   t  j   } | d d k	 s( t d   d } | d k r t | d t  r t | d d d  } | d k r t | d  } n  | r | j |  j  r d } q n  |  | |  S(   sK  returns an ExceptionInfo matching the current traceback

        .. warning::

            Experimental API


        :param exprinfo: a text string helping to determine if we should
                         strip ``AssertionError`` from the output, defaults
                         to the exception message/``__str__()``
        i    s   no current exceptionRD   i   t   msgs   AssertionError: N(	   t   syst   exc_infoR8   R[   R   t   getattrR   t
   startswitht   _assert_start_repr(   t   clsR|   t   tupt
   _striptext(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   from_current  s    c         C` s
   |  d  S(   s)   return an unfilled ExceptionInfo
        N(   R8   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt	   for_later  s    c         C` s   |  j  d S(   s   the exception classi    (   RT   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s    c         C` s   |  j  d S(   s   the exception valuei   (   RT   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   value  s    c         C` s   |  j  d S(   s   the exception raw tracebacki   (   RT   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s    c         C` s
   |  j  j S(   s   the type name of the exception(   R   R5   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   typename  s    c         C` s7   |  j  d k r0 t |  j d t |   |  _  n  |  j  S(   s   the tracebackRX   N(   t
   _tracebackR8   R~   R   R   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt	   traceback  s    !c         C` s   | |  _  d  S(   N(   R   (   R   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s    c         C` s-   |  j  d  k r d Sd |  j t |  j  f S(   Ns)   <ExceptionInfo for raises contextmanager>s   <ExceptionInfo %s tblen=%d>(   RT   R8   R   R   R   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyRa     s    c         C` se   t  |  j |  j  } d j |  } | j   } | ra | j |  j  ra | t |  j  } qa n  | S(   s4   return the exception as a string

            when 'tryshort' resolves to True, and the exception is a
            _pytest._code._AssertionError, only the actual exception part of
            the exception representation is returned (so 'AssertionError: ' is
            removed from the beginning)
        RD   (   R   R   R   t   joint   rstripR   R   R   (   R   t   tryshortt   linest   text(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   exconly  s    c         C` s   t  |  j |  S(   s4    return True if the exception is an instance of exc (   R   R   (   R   t   exc(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   errisinstance  s    c         C` sQ   |  j  d t  } |  j j   } | j j j j | j } } t	 | | d |  S(   NR   i   (
   R   t   TrueR   R   RC   RB   R   R   R>   t   ReprFileLocation(   R   R   R   R!   R>   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   _getreprcrash  s    RZ   c   	      C` s   | d k rD t  t t j |  j |  j |  j d j   |  j    St d | d | d | d | d | d | d	 |  } | j	 |   S(
   s  
        Return str()able representation of this exception info.

        :param bool showlocals:
            Show locals per traceback entry.
            Ignored if ``style=="native"``.

        :param str style: long|short|no|native traceback style

        :param bool abspath:
            If paths should be changed to absolute or left unchanged.

        :param bool tbfilter:
            Hide entries that contain a local variable ``__tracebackhide__==True``.
            Ignored if ``style=="native"``.

        :param bool funcargs:
            Show fixtures ("funcargs" for legacy purposes) per traceback entry.

        :param bool truncate_locals:
            With ``showlocals==True``, make sure locals can be safely represented as strings.

        :param bool chain: if chained exceptions in Python 3 should be shown.

        .. versionchanged:: 3.9

            Added the ``chain`` parameter.
        t   nativei    t
   showlocalst   stylet   abspatht   tbfiltert   funcargst   truncate_localst   chain(
   t   ReprExceptionInfot   ReprTracebackNativeR   t   format_exceptionR   R   RU   R   t   FormattedExcinfot   repr_excinfo(	   R   R   R   R   R   R   R   R   t   fmt(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   getrepr  s    &	c         C` sR   |  j  d  k r t |   S|  j d } t | j | j d |  j    } t |  S(   Nii   (	   RT   R8   RM   R   R   R!   R>   R   Rt   (   R   R   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR{   *  s
    
"c         C` s9   |  j  d } t | j | j d |  j    } t |  S(   Nii   (   R   R   R!   R>   R   R   (   R   R   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   __unicode__1  s    "c         C` sI   t  } t j | t |  j   sE d sE t d j | |  j    n  t  S(   s>  
        Check whether the regular expression 'regexp' is found in the string
        representation of the exception using ``re.search``. If it matches
        then True is returned (so that it is possible to write
        ``assert excinfo.match()``). If it doesn't match an AssertionError is
        raised.
        i    s"   Pattern '{!s}' not found in '{!s}'(   R   t   ret   searchRt   R   R[   t   format(   R   t   regexpRo   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   match6  s    $N(   R5   R6   R7   R	   R   t   attrt   ibRT   R   R8   R   t   classmethodR   R   R:   R   R   R   R   R   t   setterRa   R;   R   R   R   R   R   R{   R   R   (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s8   			3		R   c           B` s4  e  Z d  Z d Z d Z e j d e  Z e j d d  Z	 e j d e
  Z e j d e
  Z e j d e  Z e j d e
  Z e j d e
  Z e j d e j e  d e d e  Z d   Z d   Z d	   Z d
 d e d  Z d e d  Z d   Z d d  Z d   Z d   Z d   Z d   Z RS(   s@    presenting information about failing Functions and Generators. t   >t   ER   RZ   t   initRM   c         C` s   y# t  | j t |  d   } WnL t k
 r9   n9 y t  | d  } Wqr t k
 rf   qr d SXn Xd t |  t | j    S(   Ni   ii    i   (   Rt   RE   R   Rx   Rw   (   R   R&   t   s(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt
   _getindentU  s    #	c         C` s1   | j  |  j  } | d  k	 r- | j   } n  | S(   N(   Rn   Rj   R8   t   deindent(   R   R   R&   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   _getentrysourced  s    c         C` s\   |  j  rX g  } x< | j j d t  D]% \ } } | j | t |  f  q% Wt |  Sd  S(   NR2   (   R   RC   R4   R   RO   R   t   ReprFuncArgs(   R   R   t   argst   argnamet   argvalue(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt	   repr_argsj  s
    	"ic   
      C` s_  d d l  } g  } | d k s3 | t | j  k rN | j j d  } d } n  | d k  rm | t |  7} n  d } | r | j | | j | j    nu x& | j |  D] } | j | |  q W| j |  j d | j |  x* | j | d D] } | j | |  q W| d k	 r[| r'd n |  j	 |  }	 | j
 |  j | d |	 d	 t  n  | S(
   s.    return formatted and marked up source lines. i    Ns   ???s       s      i   i   t   indentt   markall(   R'   R8   R   R   R,   R-   RO   t   stript   flow_markerR   t   extendt   get_exconlyR   (
   R   R&   t
   line_indexRX   RY   R.   R   t   space_prefixRz   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt
   get_sourceq  s&    !	!%i   c         C` sq   g  } d | } | j  d t  j d  } |  j | d } x. | D]& } | j | |  | sC | } qC qC W| S(   Nt    R   s   
i   (   R   R   t   splitt   fail_markerRO   (   R   RX   R   R   R   t   exlinest
   failindentRz   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s    
c         C` s   |  j  r g  } g  | D] } | d d k r | ^ q } | j   xo | D]g } | | } | d k ru | j d  qI |  j r t |  } n t |  } | j d | | f  qI Wt |  Sd  S(   Ni    t   @t   __builtins__s   __builtins__ = <builtins>s
   %-10s = %s(   R   t   sortRO   R   R   R   t
   ReprLocals(   R   R}   R   R   t   keysR   R   t   str_repr(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   repr_locals  s    	)

	c         C` s  d d  l  } |  j |  } | d  k rB | j j d  } d } n | j t | j   d  } g  } | j } | d  k r |  j	 } n  | d
 k rm| d k } | s |  j
 |  n d  }	 |  j | | | d | }
 | j |
  | r d | j } n | r| j pd } |  j | j  } t | | j d |  } d  } | sW|  j | j  } n  t | |	 | | |  S| r| j |  j | d d	  n  t | d  d  d  |  S(   Ni    s   ???RY   RZ   s   in %sRD   i   R   i   (   RY   RZ   (   R'   R   R8   R,   R-   R>   Rc   Rd   R\   R   R   R   R   R   R   t	   _makepathR!   R   R   R}   t	   ReprEntryR   (   R   R   RX   R.   R&   R   R   R   RY   t   reprargsR   t   messageR!   t   filelocreprt
   localsrepr(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   repr_traceback_entry  s6    		c         C` sh   |  j  sd y t j j   j |  } Wn t k
 r9 | SXt |  t t |   k  rd | } qd n  | S(   N(   R   R    R!   R"   t   bestrelpathR$   R   Rt   (   R   R!   t   np(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s    	c   
      C` s   | j  } |  j r! | j   } n  t |  rE |  j |  \ } } n d  } | d } g  } xQ t |  D]C \ } } | | k r | p d  } |  j | |  }	 | j |	  qh Wt	 | | d |  j
 S(   NiR   (   R   R   R   t   is_recursion_errort   _truncate_recursive_tracebackR8   R   R   RO   t   ReprTracebackR   (
   R   RX   R   t	   extralinet   lastt   entriest   indexR   t   einfot	   reprentry(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   repr_traceback  s    		
c      
   C` s   y | j    } Wne t k
 rw } d } d j d t |  j d t |  d | d t |   } | |  | | } n* X| d	 k	 r d } | | d  } n d	 } | | f S(
   sC  
        Truncate the given recursive traceback trying to find the starting point
        of the recursion.

        The detection is done by going through each traceback entry and finding the
        point in which the locals of the frame are equal to the locals of a previous frame (see ``recursionindex()``.

        Handle the situation where the recursion process might raise an exception (for example
        comparing numpy arrays using equality raises a TypeError), in which case we do our best to
        warn the user of the error and show a limited traceback.
        i
   s  !!! Recursion error detected, but an error occurred locating the origin of recursion.
  The following exception happened when comparing locals in the stack frame:
    {exc_type}: {exc_msg}
  Displaying first and last {max_frames} stack frames out of {total}.t   exc_typet   exc_msgt
   max_framest   totals/   !!! Recursion detected (same locals & position)i   N(   R   t	   ExceptionR   R   R5   R   R   R8   (   R   R   R   t   eR  R  (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR    s    	c         C` s  t  r. |  j |  } | j   } t | |  Sg  } | j } d  } t   } xT| d  k	 rt |  | k r| j t |   | r |  j |  } | j   } n' t	 t
 j t |  | d    } d  } | | | | f g 7} | j d  k	 r8|  j r8| j } | j r)t t |  | | j f  n d  } d } qO | j d  k	 r| j r|  j r| j } | j rt t |  | | j f  n d  } d } qO d  } qO W| j   t |  Sd  S(   NsD   The above exception was the direct cause of the following exception:sC   During handling of the above exception, another exception occurred:(   R	   R  R   R   R   R8   t   setR   t   addR   R   R   R   t	   __cause__R   t   __traceback__R   t   __context__t   __suppress_context__t   reverset   ExceptionChainRepr(   R   RX   t   reprtracebackt	   reprcrasht
   repr_chainR  t   descrt   seen(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s@    		!	'	
		'	

N(   R5   R6   R7   R   R   R   R   R;   R   R   R   R   R   R   R   R   t   Factoryt   dictRj   R   R   R   R8   R   R   R   R   R   R  R  R   (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR   D  s,   '				"	
		%t   TerminalReprc           B` s#   e  Z d    Z d   Z d   Z RS(   c         C` s(   |  j    } t r$ | j d  } n  | S(   Ns   utf-8(   R   R	   t   encode(   R   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR{   F  s    c         C` sA   t  j j   } t  j j d |  } |  j |  | j   j   S(   Nt   file(   R    t   iot   TextIOt   TerminalWritert
   toterminalt   getvalueR   (   R   R$  t   tw(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR   L  s    c         C` s   d |  j  t |   f S(   Ns   <%s instance at %0x>(   R   R   (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyRa   T  s    (   R5   R6   R{   R   Ra   (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR!  E  s   		t   ExceptionReprc           B` s&   e  Z d    Z d d  Z d   Z RS(   c         C` s   g  |  _  d  S(   N(   t   sections(   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR   Y  s    t   -c         C` s   |  j  j | | | f  d  S(   N(   R+  RO   (   R   R   t   contentt   sep(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt
   addsection\  s    c         C` s>   x7 |  j  D], \ } } } | j | |  | j |  q
 Wd  S(   N(   R+  R.  Rz   (   R   R)  R   R-  R.  (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR'  _  s    (   R5   R6   R   R/  R'  (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR*  X  s   	R  c           B` s   e  Z d    Z d   Z RS(   c         C` sB   t  t |   j   | |  _ | d d |  _ | d d |  _ d  S(   Nii    i   (   R   R  R   R   R  R  (   R   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR   f  s    	c         C` sv   xY |  j  D]N } | d j |  | d d  k	 r
 | j d  | j | d d t q
 q
 Wt t |   j |  d  S(   Ni    i   RD   t   yellow(   R   R'  R8   Rz   R   R   R  (   R   R)  t   element(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR'  n  s    (   R5   R6   R   R'  (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR  e  s   	R   c           B` s   e  Z d    Z d   Z RS(   c         C` s)   t  t |   j   | |  _ | |  _ d  S(   N(   R   R   R   R  R  (   R   R  R  (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR   x  s    	c         C` s*   |  j  j |  t t |   j |  d  S(   N(   R  R'  R   R   (   R   R)  (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR'  }  s    (   R5   R6   R   R'  (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR   w  s   	R  c           B` s    e  Z d  Z d   Z d   Z RS(   s   _ c         C` s   | |  _  | |  _ | |  _ d  S(   N(   t   reprentriesR  R   (   R   R2  R  R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s    		c         C` s   x t  |  j  D] \ } } | j d k r; | j d  n  | j |  | t |  j  d k  r |  j | d } | j d k s | j d k r | j d k r | j |  j  q q q W|  j r | j |  j  n  d  S(   NRZ   RD   i   RY   (	   R   R2  R   Rz   R'  R   R.  t   entrysepR  (   R   R)  R   R   t
   next_entry(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR'    s    	(   R5   R6   R3  R   R'  (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR    s   	R   c           B` s   e  Z d    Z RS(   c         C` s(   d |  _  t |  g |  _ d  |  _ d  S(   NR   (   R   t   ReprEntryNativeR2  R8   R  (   R   t   tblines(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s    	(   R5   R6   R   (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s   R5  c           B` s    e  Z d  Z d   Z d   Z RS(   R   c         C` s   | |  _  d  S(   N(   R   (   R   R6  (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s    c         C` s   | j  d j |  j   d  S(   NRD   (   t   writeR   R   (   R   R)  (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR'    s    (   R5   R6   R   R   R'  (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR5    s   	R   c           B` s#   e  Z d    Z d   Z d   Z RS(   c         C` s1   | |  _  | |  _ | |  _ | |  _ | |  _ d  S(   N(   R   t   reprfuncargst
   reprlocalst   reprfilelocR   (   R   R   R8  R9  R   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s
    				c         C` s  |  j  d k r_ |  j j |  x9 |  j D]. } | j d  } | j | d t d | q) Wd  S|  j r{ |  j j |  n  x9 |  j D]. } | j d  } | j | d t d | q W|  j r | j d  |  j j |  n  |  j r|  j r| j d  n  |  j j |  n  d  S(   NRY   s   E   t   boldt   redRD   (	   R   R:  R'  R   R   Rz   R   R8  R9  (   R   R)  Rz   R<  (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR'    s$    				c         C` s#   d d j  |  j  |  j |  j f S(   Ns   %s
%s
%ss   
(   R   R   R9  R:  (   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR{     s    (   R5   R6   R   R'  R{   (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s   		R   c           B` s   e  Z d    Z d   Z RS(   c         C` s%   t  |  |  _ | |  _ | |  _ d  S(   N(   Rt   R!   R>   R   (   R   R!   R>   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s    	c         C` sk   |  j  } | j d  } | d k r1 | |  } n  | j |  j d t d t | j d |  j | f  d  S(   Ns   
iR;  R<  s   :%s: %s(   R   t   findR7  R!   R   Rz   R>   (   R   R)  R   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR'    s    	(   R5   R6   R   R'  (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s   	R   c           B` s   e  Z d    Z d   Z RS(   c         C` s   | |  _  d  S(   N(   R   (   R   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s    c         C` s%   x |  j  D] } | j |  q
 Wd  S(   N(   R   Rz   (   R   R)  Rz   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR'    s    (   R5   R6   R   R'  (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s   	R   c           B` s   e  Z d    Z d   Z RS(   c         C` s   | |  _  d  S(   N(   R   (   R   R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s    c         C` s   |  j  r d } x |  j  D] \ } } d t |  t |  f } t |  t |  d | j k r | rz | j |  n  | } q | r | d | 7} q | } q W| r | j |  n  | j d  n  d  S(   NRD   s   %s = %si   s   , (   R   R   R   t	   fullwidthRz   (   R   R)  t	   linesofarR   R   t   ns(    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR'    s    	#	
(   R5   R6   R   R'  (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR     s   	c         C` s   y |  j  SWn t k
 r t |  d |   }  t |  d |   }  t |  d |   }  t |  d |   }  | r t |  d  r t |  d  r t j |   r t |  j d t } t | d  r | Sq n  |  SXd S(	   s(    return code object for given function. t   im_funct	   func_codeRA   t   __code__R   t   __call__t   trycallN(	   RC  R   R   R   t   inspectt   isclassR   RD  R;   (   t   objRE  R   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR      s    
c         C` s   |  j  t  S(   N(   R   t   RecursionError(   RX   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR    s    c         C` sC   |  j  t  s t Sy d t |  j  k SWn t k
 r> t SXd  S(   Ns    maximum recursion depth exceeded(   R   t   RuntimeErrorR;   Rt   R   t   UnicodeError(   RX   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyR    s    t   ocs   __init__.pyc         C` sw   |  j  j j j } d | k o' d | k } | r4 t St j j |  j  } | j t	  ov | j t
  ov | j t  S(   s   Return True if a TracebackEntry instance should be removed from tracebacks:
    * dynamically generated code (no code to show up for it);
    * internal traceback from pytest or its internal libraries, py and pluggy.
    t   <R   (   RC   RB   R   R   R;   R    R!   R"   R   t   _PLUGGY_DIRt   _PYTEST_DIRt   _PY_DIR(   R   t   raw_filenamet   is_generatedR%   (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   filter_traceback/  s    (@   t
   __future__R    R   R   RF  R   R   R   R   R   t   weakrefR   R   t   pluggyR    t   sixR   R.   t   _pytest._io.safereprR   R   t   _pytest.compatR	   R
   R   R   R   t   _py2tracebackRL   R   R<   RS   R   R~   t   compileR   R   R;   R   R   R!  R*  R  R   R  R   R5  R   R   R   R   R   R   R  R!   R"   t   __file__R   RN  t   basenamet   dirpathRO  RP  RS  (    (    (    s1   lib/python2.7/site-packages/_pytest/_code/code.pyt   <module>   sn   F?qh	 
!		