
^Yc           @` s  d  Z  d d l m Z m Z 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 m Z d d l m Z m Z d   Z d   Z d	 e j f d
     YZ d d  Z e e _ d d d     YZ e
 d e  d    Z e
 d e  d    Z d   Z d   Z e
 d e  d    Z d   Z d   Z d   Z d   Z  d   Z! d   Z" d   Z# d   Z$ d S(   s/    support for skip/xfail functions and markers. i    (   t   absolute_importt   divisiont   print_functionN(   t   hookimpl(   t   MarkInfot   MarkDecorator(   t   failt   skipc      
   C` sT   |  j  d  } | j d d d d d d t d d	 |  j d
 d d t d d d  S(   Nt   generals
   --runxfailt   actiont
   store_truet   destt   runxfailt   defaultt   helps'   run tests even if they are marked xfailt   xfail_stricts\   default for the strict parameter of xfail markers when not given explicitly (default: False)t   typet   bool(   t   getgroupt	   addoptiont   Falset   addini(   t   parsert   group(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   pytest_addoption   s    c         ` s   |  j  j rb d d  l   j   |  j j    f d    d   } t | _ t  d |  n  |  j	 d d  |  j	 d d  |  j	 d d  d  S(	   Ni    c           ` s   t   d    S(   Nt   xfail(   t   setattr(    (   t   oldt   pytest(    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   <lambda>   s    c          _` s   d  S(   N(    (   t   argst   kwargs(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   nop!   s    R   t   markerss   skip(reason=None): skip the given test function with an optional reason. Example: skip(reason="no way of currently testing this") skips the test.s  skipif(condition): skip the given test function if eval(condition) results in a True value.  Evaluation happens within the module global context. Example: skipif('sys.platform == "win32"') skips the test if we are on the win32 platform. see http://pytest.org/latest/skipping.htmls  xfail(condition, reason=None, run=True, raises=None, strict=False): mark the test function as an expected failure if eval(condition) has a True value. Optionally specify a reason for better reporting and run=False if you don't even want to execute the test function. If only specific exception(s) are expected, you can list them in raises, and if the test fails in other ways, it will be reported as a true failure. See http://pytest.org/latest/skipping.html(
   t   optionR   R   R   t   _cleanupt   appendt   XFailedt	   ExceptionR   t   addinivalue_line(   t   configR    (    (   R   R   s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   pytest_configure   s    						R%   c           B` s   e  Z d  Z RS(   s0    raised from an explicit call to pytest.xfail() (   t   __name__t
   __module__t   __doc__(    (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyR%   >   s   t    c         C` s   t  } t |    d S(   sB    xfail an executing test or setup functions with the given reason.N(   t   TrueR%   (   t   reasont   __tracebackhide__(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyR   B   s    t   MarkEvaluatorc           B` sq   e  Z d    Z e d    Z d   Z e Z d   Z d   Z d   Z	 d   Z
 d   Z d
 d  Z d	   Z RS(   c         C` s   | |  _  | |  _ d  S(   N(   t   itemt   name(   t   selfR2   R3   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   __init__L   s    	c         C` s   |  j  j j |  j  S(   N(   R2   t   keywordst   getR3   (   R4   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   holderP   s    c         C` s   t  |  j  S(   N(   R   R8   (   R4   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   __bool__T   s    c         C` s   t  |  d  S(   Nt   exc(   t   hasattr(   R4   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   wasvalidX   s    c         C` s'   |  j  d  } | s d  St | |  S(   Nt   raises(   R7   t
   isinstance(   R4   R:   R=   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   invalidraise[   s    c         C` s   y |  j    SWn t k
 r t j   |  _ t |  j d t  rr d |  j d j d d g } | j d  n t	 j
 |  j d    } t d |  j |  j d j |  f d	 t n Xd  S(
   Ni   t    i   t   ^s   SyntaxError: invalid syntaxi   s(   Error evaluating %r expression
    %s
%ss   
t   pytrace(   t   _istrueR&   t   syst   exc_infoR:   R>   t   SyntaxErrort   offsetR$   t	   tracebackt   format_exception_onlyR   R3   t   exprt   joinR   (   R4   t   msg(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   istruea   s    c         C` sP   i t  d 6t d 6|  j j d 6} t |  j d  rL | j |  j j j  n  | S(   Nt   osRD   R(   t   obj(   RN   RD   R2   R(   R;   t   updateRO   t   __globals__(   R4   t   d(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   _getglobalsq   s    !c   	      C` st  t  |  d  r |  j S|  j rd|  j j s= d |  j j k rXt |  _ t |  j d d   pg |  j j g } x | D] \ } } } d | k r | d f } n  x | D] } | |  _	 t
 | t j j  r |  j   } t |  j j | |  } n+ d | k rd } t |  n  t |  } | r t |  _ | j d d   |  _ | |  _	 |  j Sq Wqq Wqdt |  _ n  t |  d t  S(   Nt   resultt	   conditiont   _marksR/   sD   you need to specify reason=STRING when using booleans as conditions.(   R;   RT   R8   R   R   R   t   getattrt   Nonet   markRJ   R>   t   pyt   builtint   _basestringRS   t   cached_evalR2   R(   R   R   R.   R7   R/   (	   R4   t   markst   _R   R   RJ   RR   RT   RL   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyRC   w   s4    					c         C` s   |  j  j j | |  S(   N(   R8   R   R7   (   R4   t   attrR   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyR7      s    c         C` sU   t  |  d d   p! |  j d d   } | sQ t |  d  s= d Sd t |  j  Sn  | S(   NR/   RJ   R-   s   condition: (   RW   RX   R7   R;   t   strRJ   (   R4   t   expl(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   getexplanation   s    $N(   R*   R+   R5   t   propertyR8   R9   t   __nonzero__R<   R?   RM   RS   RC   RX   R7   Rc   (    (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyR1   K   s   							#t   tryfirstc         C` s   |  j  j d  } t | t t f  ra t |  d  } | j   ra | |  _ t | j	    qa n  |  j  j d  } t | t t f  r t
 |  _ d | j k r t | j d  q | j r t | j d  q t d  n  t |  d  |  _ t |   d  S(   Nt   skipifR   R/   i    s   unconditional skipR   (   R6   R7   R>   R   R   R1   RM   t	   _evalskipR   Rc   R.   R   R   t
   _evalxfailt   check_xfail_no_run(   R2   t   skipif_infot   eval_skipift	   skip_info(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   pytest_runtest_setup   s     			t   hookwrapperc         c` s7   t  |   d  V} | j d  k } | r3 t |   n  d  S(   N(   Rj   t   excinfoRX   t   check_strict_xfail(   t
   pyfuncitemt   outcomet   passed(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   pytest_pyfunc_call   s
    
c         C` sW   |  j  j j sS |  j } | j   rS | j d t  sP t d | j    qP qS n  d S(   s   check xfail(run=False)t   runs	   [NOTRUN] N(	   R(   R"   R   Ri   RM   R7   R.   R   Rc   (   R2   t	   evalxfail(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyRj      s
    	c         C` so   |  j  } | j   rk |  j j d  } | j d |  } | rk |  `  | j   } t d | d t qk n  d S(   s3   check xfail(strict=True) for the given PASSING testR   t   stricts   [XPASS(strict)] RB   N(   Ri   RM   R(   t   getiniR7   Rc   R   R   (   Rr   Rw   t   strict_defaultt   is_strict_xfailt   explanation(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyRq      s    	c         c` s^  d  V} | j    } t |  d d   } t |  d d   } t |  d  r | j d k r d d l m } |  j r d j |  j  | _	 n	 d | _	 |   r d	 | _
 qZd
 | _
 | j	 | _ n|  j j j r n| j r| j j t j  rd | j j j | _ d | _
 nL| r| j r| j   r| j   r| j r{| j | j j  r`d	 | _
 qd | _
 | j   | _ qZ| j d k rZ|  j j d  } | j d |  } | j   }	 | rd	 | _
 d j |	  | _	 qd
 | _
 |	 | _ qZnd | d  k	 rZ| j rZt | j	  t k rZ| j	 \ }
 } } |  j d  \ }
 } |
 | | f | _	 n  d  S(   NRi   Rh   t   _unexpectedsuccesst   calli    (   t)   _is_unittest_unexpected_success_a_failures   Unexpected success: {0}s   Unexpected successt   failedRt   s   reason: t   skippedR   Rx   s   [XPASS(strict)] {0}i   (   t
   get_resultRW   RX   R;   t   whent   _pytest.compatR   R}   t   formatt   longreprRs   t   wasxfailR(   R"   R   Rp   t   errisinstanceR   R&   t   valueRL   R   R<   RM   R?   Rc   Ry   R7   R   t   tuplet   location(   R2   R~   Rs   t   repRw   t   evalskipR   Rz   R{   R|   t   filenamet   lineR/   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   pytest_runtest_makereport   sL    								*c         C` sF   t  |  d  rB |  j r d	 S|  j rB d d d i t d 6f f Sn  d  S(
   NR   t   xfailedt   xR   t   xpassedt   Xt   XPASSt   yellow(   s   xfailedR   s   xfail(   R;   R   Rt   R.   (   t   report(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   pytest_report_teststatus  s
    		c         C` s(  |  } | j  s d  Sg  } x | j  D] } | d k rE t |  |  q# | d k ra t |  |  q# | d k r t |  | d d  q# | d k r t |  |  q# | d k r t |  | d d	  q# | d
 k r# t |  | d d  q# q# W| r$| j j d d  x! | D] } | j j |  qWn  d  S(   NR   R   t   fFR   s   FAIL %st   sSt   Et   errors   ERROR %st   pRt   s	   PASSED %st   =s   short test summary info(   t   reportcharst   show_xfailedt   show_xpassedt   show_simplet   show_skippedt   _twt   sepR   (   t   terminalreportert   trt   linest   charR   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   pytest_terminal_summary  s*    	c         C` sY   |  j  j |  } | rU x: | D]/ } |  j j | j  } | j | | f  q Wn  d  S(   N(   t   statsR7   R(   t   cwd_relative_nodeidt   nodeidR$   (   R   R   t   statR   R   R   t   pos(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyR   7  s
    c         C` s   |  j  j d  } | r~ xc | D]X } |  j j | j  } | j } | j d | f  | r | j d t |   q q Wn  d  S(   NR   s   XFAIL %ss     (   R   R7   R(   R   R   R   R$   Ra   (   R   R   R   R   R   R/   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyR   ?  s    	c         C` se   |  j  j d  } | ra xF | D]; } |  j j | j  } | j } | j d | | f  q Wn  d  S(   NR   s   XPASS %s %s(   R   R7   R(   R   R   R   R$   (   R   R   R   R   R   R/   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyR   J  s    	c         C` s   t  |  d  s i  |  _ n  y |  j | SWnP t k
 r| d d  l } | j j | d d } t | |  |  j | <} | SXd  S(   Nt
   _evalcachei    t   modet   eval(   R;   R   t   KeyErrort   _pytest._codet   _codet   compileR   (   R(   RJ   RR   t   _pytestt   exprcodeR   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyR]   S  s    c         C` s   i  } xT |  D]L } | j  } t |  d k s@ t | | f   | j | g   j |  q Wg  } x4 | j   D]& \ } } | j t |  f |  qp W| S(   Ni   (   R   t   lent   AssertionErrort
   setdefaultR$   t   items(   R   RR   t   eventt   keyt   lt   events(    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   folded_skips_  s    	$c   	      C` s   |  } | j  j d g   } | r t |  } | r xV | D]K \ } } } } | j d  rh | d } n  | j d | | | | f  q: Wq n  d  S(   NR   s	   Skipped: i	   s   SKIP [%d] %s:%d: %s(   R   R7   R   t
   startswithR$   (	   R   R   R   R   t   fskipst   numt   fspatht   linenoR/   (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyR   k  s    (    (%   R,   t
   __future__R    R   R   RN   RD   RH   RZ   t   _pytest.configR   t   _pytest.markR   R   t   _pytest.runnerR   R   R   R)   R&   R%   R   R1   R.   Rn   Ru   Rj   Rq   R   R   R   R   R   R   R]   R   R   (    (    (    s0   /tmp/pip-build-hU8Cw8/pytest/_pytest/skipping.pyt   <module>   s6   		$	\				2								