ó
¾^Yc           @` sx   d  Z  d d l m Z m Z m Z d d l Z d d l Z d   Z d   Z d   Z	 d   Z
 d e f d	     YZ d S(
   sM    log machine-parseable test session result information in a plain
text file.
i    (   t   absolute_importt   divisiont   print_functionNc         C` s>   |  j  d d  } | j d d d d d d d	 d  d
 d d  S(   Ns   terminal reportings   resultlog plugin optionss   --resultlogs   --result-logt   actiont   storet   metavart   patht   defaultt   helps0   DEPRECATED path for machine-readable result log.(   t   getgroupt	   addoptiont   None(   t   parsert   group(    (    s1   /tmp/pip-build-hU8Cw8/pytest/_pytest/resultlog.pyt   pytest_addoption	   s    c         C` sĄ   |  j  j } | r¼ t |  d  r¼ t j j t j j |   } t j j |  sb t j |  n  t	 | d d  } t
 |  |  |  _ |  j j |  j  d d l m } |  j d |  n  d  S(   Nt
   slaveinputt   wi   i    (   t
   RESULT_LOGt   C1(   t   optiont	   resultlogt   hasattrt   osR   t   dirnamet   abspatht   isdirt   makedirst   opent	   ResultLogt
   _resultlogt   pluginmanagert   registert   _pytest.deprecatedR   t   warn(   t   configR   R   t   logfileR   (    (    s1   /tmp/pip-build-hU8Cw8/pytest/_pytest/resultlog.pyt   pytest_configure   s    c         C` sB   t  |  d d   } | r> | j j   |  ` |  j j |  n  d  S(   NR   (   t   getattrR   R#   t   closeR   R   t
   unregister(   R"   R   (    (    s1   /tmp/pip-build-hU8Cw8/pytest/_pytest/resultlog.pyt   pytest_unconfigure   s
    c         C` sŽ   |  j    } | d j g } | d j } t } x | d D] } | j } | | k r | rq | j d  t } q | j d  n | j d  t } | j } | d d k rŗ | j   n  | j |  | } q: Wd j |  S(   Ni    i   t   :t   .t   /s   ([t    (   t	   listchaint   namet   fspatht   Falset   appendt   Truet   popt   join(   t   itemt   chaint   gpathR/   t   fspartt   nodet	   newfspathR.   (    (    s1   /tmp/pip-build-hU8Cw8/pytest/_pytest/resultlog.pyt   generic_path$   s&    			
R   c           B` s>   e  Z d    Z d   Z d   Z d   Z d   Z d   Z RS(   c         C` s   | |  _  | |  _ d  S(   N(   R"   R#   (   t   selfR"   R#   (    (    s1   /tmp/pip-build-hU8Cw8/pytest/_pytest/resultlog.pyt   __init__<   s    	c         C` sO   t  d | | f d |  j x+ | j   D] } t  d | d |  j q* Wd  S(   Ns   %s %st   files    %s(   t   printR#   t
   splitlines(   R<   t   testpatht
   lettercodet   longreprt   line(    (    s1   /tmp/pip-build-hU8Cw8/pytest/_pytest/resultlog.pyt   write_log_entry@   s    c         C` sA   t  | d d   } | d  k r* | j } n  |  j | | |  d  S(   Nt   nodeid(   R%   R   R/   RE   (   R<   t   reportRB   RC   RA   (    (    s1   /tmp/pip-build-hU8Cw8/pytest/_pytest/resultlog.pyt   log_outcomeE   s    c         C` sŌ   | j  d k r | j r d  S|  j j j d |  } | d } | d k r\ t | j  } na | d k rq d } nL | j r d } n: | j r t | j  } n | j r½ t | j d  } n  |  j	 | | |  d  S(   Nt   callRG   i   t   xt   XR,   i   (
   t   whent   passedR"   t   hookt   pytest_report_teststatust   strRC   t   failedt   skippedRH   (   R<   RG   t   rest   codeRC   (    (    s1   /tmp/pip-build-hU8Cw8/pytest/_pytest/resultlog.pyt   pytest_runtest_logreportK   s    
					c         C` sf   | j  sb | j r* d } t | j  } n" | j s9 t  d } d | j } |  j | | |  n  d  S(   Nt   Ft   Ss	   %s:%d: %s(   RM   RQ   RP   RC   RR   t   AssertionErrorRH   (   R<   RG   RT   RC   (    (    s1   /tmp/pip-build-hU8Cw8/pytest/_pytest/resultlog.pyt   pytest_collectreport\   s    		c         C` sc   t  | d d   } t  | d d   } | d  k rF d t j j   } n  |  j | d t |   d  S(   Nt	   reprcrashR   s   cwd:%st   !(   R%   R   t   pyR   t   localRE   RP   (   R<   t   excreprRZ   R   (    (    s1   /tmp/pip-build-hU8Cw8/pytest/_pytest/resultlog.pyt   pytest_internalerrorg   s
    (   t   __name__t
   __module__R=   RE   RH   RU   RY   R_   (    (    (    s1   /tmp/pip-build-hU8Cw8/pytest/_pytest/resultlog.pyR   ;   s   					(   t   __doc__t
   __future__R    R   R   R\   R   R   R$   R(   R;   t   objectR   (    (    (    s1   /tmp/pip-build-hU8Cw8/pytest/_pytest/resultlog.pyt   <module>   s   				