σ
Ύ^Yc           @` s   d  d l  m Z m Z m Z d  d l Z d  d l m Z d  d l Z d  d l m	 Z	 d   Z
 d   Z e d    Z e j d e  d	    Z d S(
   i    (   t   absolute_importt   divisiont   print_functionN(   t   contextmanager(   t   compatc   	      C` s-  | j  d  } t |  d k r: |  j d | f   n  x# t |  d k  r_ | j d  q= Wg  | D] } | j   ^ qg \ } } } } } |  j |  } |  j |  } | r
y% t |  } | d k  rΦ t  n  Wqt t	 f k
 r|  j d | f   qXn d } |  j
 | | | | |  d S(   sP   
    Copy of the warning._setoption function but does not escape arguments.
    t   :i   s   too many fields (max 5): %rt    i    s   invalid lineno %rN(   t   splitt   lent   _OptionErrort   appendt   stript
   _getactiont   _getcategoryt   intt
   ValueErrort   OverflowErrort   filterwarnings(	   t   wmodt   argt   partst   st   actiont   messaget   categoryt   modulet   lineno(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/warnings.pyt
   _setoption   s$    +c         C` sH   |  j  d  } | j d d d d d d |  j d d	 d
 d d d  S(   Ns   pytest-warningss   -Ws   --pythonwarningsR   R
   t   helps=   set which warnings to report, see -W option of python itself.R   t   typet   linelists   Each line specifies warning filter pattern which would be passedto warnings.filterwarnings. Process after -W and --pythonwarnings.(   t   getgroupt	   addoptiont   addini(   t   parsert   group(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/warnings.pyt   pytest_addoption$   s    c         c` s`  |  j  j d  p g  } |  j  j d  } t j d t  } x | D] } t j |  qF Wx | D] } t t |  qd Wd VxΣ | D]Λ } | j } t } t	 j
 rώ t d   | j D  rώ g  | j D] } t	 j |  ^ qΘ }	 | j |	 k } |	 | _ n  t j | | j | j | j | j  }
 |  j d |
  | r t j d |
 t  q q WWd QXd S(   s‘   
    catches the warnings generated during setup/call/teardown execution
    of the given item and after it is done posts them as warnings to this
    item.
    t   pythonwarningsR   t   recordNc         s` s!   |  ] } t  | t j  Vq d  S(   N(   t
   isinstanceR   t   UNICODE_TYPES(   t   .0t   m(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/warnings.pys	   <genexpr>D   s    t   unuseds\   Warning is using unicode non convertible to ascii, converting to a safe representation:
  %s(   t   configt	   getoptiont   getinit   warningst   catch_warningst   TrueR   R   t   FalseR   t   _PY2t   anyt   argst   safe_strt   formatwarningR   t   filenameR   t   linet   warnt   UnicodeWarning(   t   itemR5   t
   inifilterst   logR   t   warningt   warn_msgt   unicode_warningR*   t   new_argst   msg(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/warnings.pyt   catch_warnings_for_item.   s0    	"%	t   hookwrapperc         c` s   t  |   
 d  VWd  QXd  S(   N(   RD   (   R<   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/warnings.pyt   pytest_runtest_protocolU   s    (   t
   __future__R    R   R   R/   t
   contextlibR   t   pytestt   _pytestR   R   R$   RD   t   hookimplR1   RF   (    (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/warnings.pyt   <module>   s   		
'