ó
çiõ\c           @   sX  d  d l  m  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 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 d  d l m Z d  d l m Z d „  Z d e f d „  ƒ  YZ d „  Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d „  Z d S(   iÿÿÿÿ(   t   pprintN(   t   ExceptionInfo(   t	   ReprEntry(   t   ReprEntryNative(   t   ReprExceptionInfo(   t   ReprFileLocation(   t   ReprFuncArgs(   t
   ReprLocals(   t   ReprTraceback(   t   TerminalRepr(   t   skip(   t   Pathc         C   sh   y |  j  SWnV t k
 rc |  j } d | d d  } d | d | d | | d f |  _  } | SXd  S(   Ns   %s.%s.%st   version_infoi   s   [%s] %s -- Python %s %st   idt   sysplatformt
   executable(   t   _slaveinfocachet   AttributeErrort	   slaveinfo(   t   nodet   dt   vert   s(    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   getslaveinfoline   s    	t
   BaseReportc           B   sæ   e  Z d Z d Z d  „  Z d „  Z d „  Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d	 „  ƒ Z e d
 „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z e d „  ƒ Z RS(   c         K   s   |  j  j | ƒ d  S(   N(   t   __dict__t   update(   t   selft   kw(    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   __init__'   s    c         C   s–   t  |  d ƒ r( | j t |  j ƒ ƒ n  |  j } | d  k rA d  St  | d ƒ r` | j | ƒ n2 y | j | ƒ Wn t k
 r‘ | j d ƒ n Xd  S(   NR   t
   toterminals   <unprintable longrepr>(   t   hasattrt   lineR   R   t   longreprt   NoneR   t   UnicodeEncodeError(   R   t   outR!   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyR   *   s    	c         c   s;   x4 |  j  D]) \ } } | j | ƒ r
 | | f Vq
 q
 Wd  S(   N(   t   sectionst
   startswith(   R   t   prefixt   namet   content(    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   get_sections:   s    c         C   sD   t  j j d t ƒ } t | _ |  j | ƒ | j j ƒ  } | j	 ƒ  S(   sˆ   
        Read-only property that returns the full string representation
        of ``longrepr``.

        .. versionadded:: 3.0
        t   stringio(
   t   pyt   iot   TerminalWritert   Truet   Falset	   hasmarkupR   R+   t   getvaluet   strip(   R   t   twt   exc(    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   longreprtext?   s
    	c         C   s    d j  d „  |  j d ƒ Dƒ ƒ S(   s^   Return captured log lines, if log capturing is enabled

        .. versionadded:: 3.5
        s   
c         s   s   |  ] \ } } | Vq d  S(   N(    (   t   .0R'   R)   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pys	   <genexpr>T   s    s   Captured log(   t   joinR*   (   R   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   caplogM   s    c         C   s    d j  d „  |  j d ƒ Dƒ ƒ S(   sa   Return captured text from stdout, if capturing is enabled

        .. versionadded:: 3.0
        t    c         s   s   |  ] \ } } | Vq d  S(   N(    (   R7   R'   R)   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pys	   <genexpr>^   s    s   Captured stdout(   R8   R*   (   R   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt	   capstdoutW   s    c         C   s    d j  d „  |  j d ƒ Dƒ ƒ S(   sa   Return captured text from stderr, if capturing is enabled

        .. versionadded:: 3.0
        R:   c         s   s   |  ] \ } } | Vq d  S(   N(    (   R7   R'   R)   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pys	   <genexpr>h   s    s   Captured stderr(   R8   R*   (   R   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt	   capstderra   s    c         C   s   |  j  d k S(   Nt   passed(   t   outcome(   t   x(    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   <lambda>k   R:   c         C   s   |  j  d k S(   Nt   failed(   R>   (   R?   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyR@   l   R:   c         C   s   |  j  d k S(   Nt   skipped(   R>   (   R?   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyR@   m   R:   c         C   s   |  j  j d ƒ d S(   Ns   ::i    (   t   nodeidt   split(   R   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   fspatho   s    c         C   s   t  S(   sP  
        **Experimental**

        Returns True if this report should be counted towards the totals shown at the end of the
        test session: "1 passed, 1 failure, etc".

        .. note::

            This function is considered **experimental**, so beware that it is subject to changes
            even in patch releases.
        (   R/   (   R   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   count_towards_summarys   s    c         C   s)   |  j  d k	 r% |  j  \ } } } | Sd S(   s´  
        **Experimental**

        Returns the head line shown with longrepr output for this report, more commonly during
        traceback representation during failures::

            ________ Test.foo ________


        In the example above, the head_line is "Test.foo".

        .. note::

            This function is considered **experimental**, so beware that it is subject to changes
            even in patch releases.
        N(   t   locationR"   (   R   RE   t   linenot   domain(    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt	   head_line‚   s    c         C   s(   | j  j d |  d | ƒ \ } } } | S(   Nt   reportt   config(   t   hookt   pytest_report_teststatus(   R   RL   t	   _categoryt   _shortt   verbose(    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   _get_verbose_word˜   s    c         C   së   d „  } |  j  j ƒ  } t |  j d ƒ rz t |  j d ƒ ra t |  j d ƒ ra | |  ƒ | d <q‡ t j |  j ƒ | d <n |  j | d <x] | D]U } t | | t j j	 t
 f ƒ rÊ t | | ƒ | | <qŽ | d k rŽ d | | <qŽ qŽ W| S(   sè   
        This was originally the serialize_report() function from xdist (ca03269).

        Returns the contents of this report as a dict of builtin entries, suitable for
        serialization.

        Experimental method.
        c         S   së   |  j  j j j ƒ  } |  j  j j j ƒ  } g  } x | d D]ƒ } i t | ƒ j d 6| j j ƒ  d 6} xG | d j ƒ  D]5 \ } } t | d ƒ rx | j j ƒ  | d | <qx qx W| j	 | ƒ q; W| | d <i | d 6| d 6|  j  j
 d 6S(   Nt   reprentriest   typet   dataR   t	   reprcrasht   reprtracebackR%   (   R!   RW   R   t   copyRV   RT   t   __name__t   itemsR   t   appendR%   (   t   repRW   RV   t   new_entriest   entryt
   entry_datat   keyt   value(    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   disassembled_report¨   s     
R   RW   RV   R!   t   resultN(   R   RX   R   R!   t   sixt	   text_typet
   isinstanceR,   t   patht   localR   t   strR"   (   R   Rb   R   R(   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   _to_jsonž   s    
	c         C   sÍ  | d rÃd | d k rÃd | d k rÃ| d d } | d d } g  } d } x| d D]} | d } | d } | d k r"d }	 d }
 d } | d r² t | d   }	 n  | d	 rÏ t | d	   }
 n  | d
 rð t | d
 d ƒ } n  t d | d d |	 d
 | d |
 d | d ƒ } n/ | d k rAt | d ƒ } n t | |  | ƒ | j | ƒ q] W| | d <t d t	 |   d t |   ƒ } x# | d d D] } | j
 | Œ  qœW| | d <qÃn  |  |   S(   s.  
        This was originally the serialize_report() function from xdist (ca03269).

        Factory method that returns either a TestReport or CollectReport, depending on the calling
        class. It's the callers responsibility to know which class to pass here.

        Experimental method.
        R!   RV   RW   RS   RU   RT   R   t   reprfuncargst   reprfileloct
   reprlocalst   linest   filelocreprt   styleR   R%   N(   R"   R   R   R   R   R   t   _report_unserialization_failureR[   R   R   t
   addsection(   t   clst
   reportdictRW   RV   t   unserialized_entriest	   reprentryR_   RU   t
   entry_typeRk   Rl   Rm   t   exception_infot   section(    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt
   _from_jsonÐ   sL    








N(   RY   t
   __module__R"   t   whenRG   R   R   R*   t   propertyR6   R9   R;   R<   R=   RA   RB   RE   RF   RJ   RR   Rj   t   classmethodRz   (    (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyR   #   s$   			


		2c         C   sŸ   d } t  j j ƒ  } t d d d | ƒt d |  d | ƒt d | d | ƒt | d | ƒt d | d | ƒt d d d | ƒt | j ƒ  ƒ ‚ d  S(   Ns+   https://github.com/pytest-dev/pytest/issuest   -id   t   streams.   INTERNALERROR: Unknown entry type returned: %ss   report_name: %ss   Please report this bug at %s(   R,   R-   t   TextIOR    t   RuntimeErrorR2   (   t	   type_namet   report_classRt   t   urlR€   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyRq     s    t
   TestReportc           B   s>   e  Z d  Z e Z d d d d „ Z d „  Z e d „  ƒ Z	 RS(   sY    Basic test report object (also used for setup and teardown calls if
    they fail).
    i    c
         K   sw   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ t |	 pB g  ƒ |  _ t | ƒ |  _ | |  _	 |  j
 j |
 ƒ d  S(   N(   RC   RG   t   keywordsR>   R!   R|   t   listt   user_propertiesR%   t   durationR   R   (   R   RC   RG   R‡   R>   R!   R|   R%   RŠ   R‰   t   extra(    (    s.   lib/python2.7/site-packages/_pytest/reports.pyR      s    							c         C   s#   d |  j  j |  j |  j |  j f S(   Ns   <%s %r when=%r outcome=%r>(   t	   __class__RY   RC   R|   R>   (   R   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   __repr__Q  s
    	c         C   si  | j  } | j | j } d „  | j Dƒ } | j } g  } | j sS d } d }	 n® t | t ƒ sq d } | }	 n | j t	 j
 ƒ r¶ d } | j ƒ  }
 t |
 j ƒ |
 j |
 j f }	 nK d } | j  d k rÝ | j | ƒ }	 n$ | j | d | j j d d ƒ ƒ}	 x7 | j D], \ } } } | j d	 | | f | f ƒ qW|  | j | j | | |	 | | | d
 | j ƒS(   sb   
        Factory method to create and fill a TestReport with standard item and call info.
        c         S   s   i  |  ] } d  | “ q S(   i   (    (   R7   R?   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pys
   <dictcomp>`  s   	 R=   RA   RB   t   callRp   t   tbstylet   autos   Captured %s %sR‰   N(   R|   t   stopt   startR‡   t   excinfoR"   Rf   R   t   errisinstanceR
   t	   Exceptiont   _getreprcrashRi   Rg   RH   t   messaget   repr_failuret   _repr_failure_pyRL   t	   getoptiont   _report_sectionsR[   RC   RG   R‰   (   Rs   t   itemRŽ   R|   RŠ   R‡   R“   R%   R>   R!   t   rt   rwhenR`   R)   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   from_item_and_callY  s@    					!!(    N(
   RY   R{   t   __doc__R0   t   __test__R"   R   R   R~   RŸ   (    (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyR†     s   
'	t   CollectReportc           B   s2   e  Z d  Z d d „ Z e d „  ƒ Z d „  Z RS(   t   collectc         K   sM   | |  _  | |  _ | |  _ | p$ g  |  _ t | ƒ |  _ |  j j | ƒ d  S(   N(   RC   R>   R!   Rc   Rˆ   R%   R   R   (   R   RC   R>   R!   Rc   R%   R‹   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyR   ˆ  s    			c         C   s   |  j  d  |  j  f S(   N(   RE   R"   (   R   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyRG     s    c         C   s    d |  j  t |  j ƒ |  j f S(   Ns*   <CollectReport %r lenresult=%s outcome=%r>(   RC   t   lenRc   R>   (   R   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyR   ”  s    (    (   RY   R{   R|   R   R}   RG   R   (    (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyR¢   …  s   t   CollectErrorReprc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | |  _  d  S(   N(   R!   (   R   t   msg(    (    s.   lib/python2.7/site-packages/_pytest/reports.pyR     s    c         C   s   | j  |  j d t ƒd  S(   Nt   red(   R    R!   R/   (   R   R$   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyR      s    (   RY   R{   R   R   (    (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyR¥   œ  s   	c         C   s9   t  |  t t f ƒ r5 |  j ƒ  } |  j j | d <| Sd  S(   Nt   _report_type(   Rf   R†   R¢   Rj   RŒ   RY   (   RK   RU   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   pytest_report_to_serializable¤  s    c         C   sl   d |  k rh |  d d k r) t  j |  ƒ S|  d d k rF t j |  ƒ St sh t d j |  d ƒ ƒ ‚ n  d  S(   NR¨   R†   R¢   s(   Unknown report_type unserialize data: {}(   R†   Rz   R¢   R0   t   AssertionErrort   format(   RU   (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   pytest_report_from_serializable«  s    (   R    R,   Rd   t   _pytest._code.codeR   R   R   R   R   R   R   R   R	   t   _pytest.outcomesR
   t   _pytest.pathlibR   R   t   objectR   Rq   R†   R¢   R¥   R©   R¬   (    (    (    s.   lib/python2.7/site-packages/_pytest/reports.pyt   <module>   s*   	ê	l	