
^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	 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 Z d d l j Z d d l m Z d d l m Z d d	 l m Z m Z m Z m Z m Z m Z m Z m  Z  m! Z! m" Z" m# Z# m$ Z$ m% Z% m& Z& d d
 l' m( Z( e j) j* e j+ j, d   Z- e j) j* e j+  j.   Z/ e j) j* e j+  j.   Z0 d   Z1 d   Z2 d   Z3 d   Z4 d   Z5 d   Z6 e d e7  d    Z8 d   Z9 d   Z: e d e7  d    Z; d d  Z= d e> f d     YZ? d e? f d     YZ@ d e@ e jA f d     YZB d   ZC d    ZD d! e jE eB f d"     YZF d d#  ZG d$   ZH d% eB f d&     YZI d' eB f d(     YZJ d) e@ f d*     YZK d+ eK eB f d,     YZL d-   ZM d.   ZN d/ e> f d0     YZO d1 e jP f d2     YZQ d3   ZR d d4  ZS d d5  ZT d d d d6  ZU d7   ZV d8   ZW d9   ZX d:   ZY d;   ZZ e( j[ eZ _[ d< e> f d=     YZ\ d> e> f d?     YZ] d@ e> f dA     YZ^ dB eK e j_ e jP f dC     YZ` d S(D   s9    Python test discovery, setup and run of test functions. i    (   t   absolute_importt   divisiont   print_functionN(   t   count(   t   MarkerError(   t   hookimpl(   t   fixtures(   t   main(   t   isclasst
   isfunctiont   is_generatort   _escape_stringst
   REGEX_TYPEt   STRING_TYPESt   NoneTypet   NOTSETt   get_real_funct   getfslinenot   safe_getattrt   safe_strt   getlocationt   enum(   t   failt   occ         C` ss   |  j  j j j } d | k o' d | k } | r4 t St j j |  j  } | t k or | j	 t
  or | 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   <t   >(   t   framet   codet   rawt   co_filenamet   Falset   pyt   patht   localt   cutdir1t   reltot   cutdir2t   cutdir3(   t   entryt   raw_filenamet   is_generatedt   p(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   filter_traceback!   s    c         ` s5     f d   } d   j    f } t | d  d  |  S(   Nc         ` s5   |  j  t t d      } | d  k	 r1 | j Sd  S(   Nt   pytest(   t	   getparentt   getattrt
   __import__t   Nonet   obj(   t   selft   node(   t   name(    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   get5   s    s<   python %s object this node was collected from (can be None).(   t   lowert   propertyR/   (   R3   R4   t   doc(    (   R3   s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   pyobj_property4   s    c         C` s  |  j  d  } | j d d d d d d d t d	 d
 | j d d d d d d t d	 d |  j d d d d g  d	 d |  j d d d d d d g d	 d |  j d d d d d g d	 d |  j d d d d d g d	 d | j d d d d d d g d d  d	 d! d  S("   Nt   generals
   --fixturess
   --funcargst   actiont
   store_truet   destt   showfixturest   defaultt   helps4   show available fixtures, sorted by plugin appearances   --fixtures-per-testt   show_fixtures_per_tests   show fixtures per testt   usefixturest   typet   argss5   list of default fixtures to be used with this projectt   python_filess	   test_*.pys	   *_test.pys9   glob-style file patterns for Python test module discoveryt   python_classest   Tests6   prefixes or glob names for Python test class discoveryt   python_functionst   testsD   prefixes or glob names for Python test function and method discoverys   --import-modet   prependt   choicest   appendt
   importmodesN   prepend/append to sys.path when importing test modules, default is to prepend.(   t   getgroupt	   addoptionR   t   addini(   t   parsert   group(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   pytest_addoption>   s,    c         C` s8   |  j  j r t |   d S|  j  j r4 t |   d Sd  S(   Ni    (   t   optionR=   R@   (   t   config(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   pytest_cmdline_main[   s    

c         C` s   d d d g } xG | D]? } t  |  j |  r d } t | j |  j j |    q q Wy |  j j } Wn t k
 r} d  SXx$ | D] } |  j | j | j   q Wd  S(   Nt   parameterizet   parametriset   parameterises/   {0} has '{1}', spelling should be 'parametrize'(	   t   hasattrt   functionR   t   formatt   __name__t   parametrizet   AttributeErrorRC   t   kwargs(   t   metafunct   alt_spellingst   attrt   msgt   markerst   marker(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   pytest_generate_testsd   s    %c         C` s$   |  j  d d  |  j  d d  d  S(   NRd   s  parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see http://pytest.org/latest/parametrize.html for more info and examples.s   usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see http://pytest.org/latest/fixture.html#usefixtures (   t   addinivalue_line(   RT   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   pytest_configures   s    			t   trylastc         C` sg   |  j  } |  j   r% | |  j   n> |  j } i  } x" |  j j D] } | | | | <qA W| |   t S(   N(   R0   t   _isyieldedfunctiont   _argst   funcargst   _fixtureinfot   argnamest   True(   t
   pyfuncitemt   testfunctionRl   t   testargst   arg(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   pytest_pyfunc_call   s    		
c         C` s   |  j  } | d k r | j j |   s^ x4 | j j d  D] } |  j |  r: Pq: q: Wd  Sn  | j j |   } | j d |  d |  Sd  S(   Ns   .pyRD   R    t   parent(   t   extt   sessiont
   isinitpathRT   t   getinit   fnmatcht   gethookproxyt   pytest_pycollect_makemodule(   R    Ru   Rv   t   patt   ihook(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   pytest_collect_file   s    	c         C` s   t  |  |  S(   N(   t   Module(   R    Ru   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR|      s    t   hookwrapperc         c` s0  d  V} | j    } | d  k	 r# d  St |  ro |  j | |  r,|  j d  } | j | | d |   q,n |  j | |  r,t | d |  } t |  p t t	 |   s |  j
 d d d d |  q,t | d t  r,t |  rt | d |  } n t |  j | |   } | j |  q,n  d  S(	   Nt   ClassRu   t   __func__R   t   C2t   messages/   cannot collect %r because it is not a function.t   __test__(   t
   get_resultR/   R   t   istestclasst   _getcustomclasst   force_resultt   istestfunctionR-   R	   R   t   warnRo   R
   t	   Generatort   listt   _genfunctions(   t	   collectorR3   R0   t   outcomet   resR   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   pytest_pycollect_makeitem   s&    c         C` s   d  S(   N(   R/   (   RT   t   valt   argname(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   pytest_make_parametrize_id   s    t   PyobjContextc           B` s,   e  Z e d   Z e d  Z e d  Z RS(   R   R   t   Instance(   R\   t
   __module__R8   t   modulet   clst   instance(    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR      s   t
   PyobjMixinc           B` sD   e  Z d    Z e   Z d   Z e e d  Z d   Z d   Z RS(   c          C` s%   d   }  d   } t  |  | d  d  S(   Nc         S` s8   t  |  d d   } | d  k r4 |  j   |  _ } n  | S(   Nt   _obj(   R-   R/   t   _getobjR   (   R1   R0   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   fget   s    c         S` s   | |  _  d  S(   N(   R   (   R1   t   value(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   fset   s    s   underlying python object(   R6   R/   (   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR0      s    		c         C` s   t  |  j j |  j  S(   N(   R-   Ru   R0   R3   (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR      s    c         C` s   |  j    } | j   g  } x | D]y } t | t  r> q# n  | j } t | t  r t j j |  d } | r | r | j	 |  n  Pq n  | j	 |  q# W| j   d j
 |  } | j d d  S(   s7    return python path relative to the containing module. i    t   .s   .[t   [(   t	   listchaint   reverset
   isinstanceR   R3   R   t   osR    t   splitextRK   t   joint   replace(   R1   t   stopatmodulet   includemodulet   chaint   partsR2   R3   t   s(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt
   getmodpath   s"    
	
c         C` s   t  |  j  S(   N(   R   R0   (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   _getfslineno   s    c         C` s   |  j  } t | d d   } t | t  rb t j | j j } | j	 d  rY | d  } n  | } n t
 |  \ } } |  j   } t | t  s t  | | | f S(   Nt   compat_co_firstlinenos   .pyci(   R0   R-   R/   R   t   intt   syst   modulesR   t   __file__t   endswithR   R   t   AssertionError(   R1   R0   R   t   fspatht   linenot   modpath(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt
   reportinfo   s    		(	   R\   R   R0   R   Ro   R   R   R   R   (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR      s   				t   PyCollectorc           B` sY   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   c         C` s   |  j  d |  S(   NRG   (   t   _matches_prefix_or_glob_option(   R1   R3   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   funcnamefilter  s    c         C` s   t  | d t  t k S(   sg    Look for the __test__ attribute, which is applied by the
        @nose.tools.istest decorator
        R   (   R   R   Ro   (   R1   R0   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt
   isnosetest  s    c         C` s   |  j  d |  S(   NRE   (   R   (   R1   R3   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   classnamefilter  s    c         C` sC   |  j  |  s |  j |  oB t | d t  oB t j |  d  k S(   Nt   __call__(   R   R   R   R   R   t   getfixturemarkerR/   (   R1   R0   R3   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    c         C` s   |  j  |  p |  j |  S(   N(   R   R   (   R1   R0   R3   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    c         C` sn   xg |  j  j |  D]S } | j |  r, t Sd | k sP d | k sP d | k r t j | |  r t Sq Wt S(   ss   
        checks if the given name matches the prefix or glob-pattern defined
        in ini configuration.
        t   *t   ?R   (   RT   Ry   t
   startswithRo   Rz   R   (   R1   t   option_nameR3   RS   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    $c   	      C` s   t  |  j d t  s g  St  |  j d i   g } x- t j |  j j  D] } | j | j  qG Wi  } g  } x | D] } x t | j	    D]t \ } } | | k r q n  t | | <|  j
 | |  } | d  k r q n  t | t  s | g } n  | j |  q Wqt W| j d d    | S(   NR   t   __dict__t   keyc         S` s   |  j    d  S(   Ni   (   R   (   t   item(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   <lambda>@  s    (   R-   R0   Ro   t   inspectt   getmrot	   __class__RK   R   R   t   itemst   makeitemR/   R   t   extendt   sort(	   R1   t   dictst   baseclst   seent   lt   dicR3   R0   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   collect*  s(    
c         C` s   |  j  j d |  d | d |  S(   NR   R3   R0   (   R~   R   (   R1   R3   R0   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR   C  s    c         c` s  |  j  t  j } |  j  t  } | r0 | j p3 d  } t | | |  |  j j } | j |  | |  } t	 | | |  j
 d | d | } g  }	 t | d  r |	 j | j  n  t | d  r |	 j |   j  n  |	 r |  j j j |	 t d |   n |  j j d |  |  j d  }
 | j sB|
 | d |  d | Vnv t j |  | |  x` | j D]U } d | | j f } |
 d	 | d |  d
 | d | d | d i t | j 6d |  Vq_Wd  S(   NR   R   Rf   R`   t   FunctionRu   t   fixtureinfos   %s[%s]R3   t   callspect   callobjt   keywordst   originalname(   R,   R   R0   R   R/   t   transfer_markersRw   t   _fixturemanagert   getfixtureinfot   MetafuncRT   RY   RK   Rf   R~   t
   call_extrat   dictR   t   _callsR   t   add_funcarg_pseudo_fixture_deft   idRo   (   R1   R3   t   funcobjR   t   clscolR   t   fmR   R`   t   methodsR   R   t   subname(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR   H  s8    	(   R\   R   R   R   R   R   R   R   R   R   R   (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR      s   									c         C` sM   y t  |  | j  } Wn t k
 r* t SX| j | j k oL | j | j k S(   s    Returns True if :func: is already marked with :mark:, False otherwise.
    This can happen if marker is applied to class and the test file is
    invoked more than once.
    (   R-   R3   R^   R   RC   R_   (   t   funct   markt	   func_mark(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   _markedm  s
    c         C` s   x | | f D] } y | j  } Wn t k
 r6 q n Xt | t  rv xI | D]" } t |  |  sM | |   qM qM Wq t |  |  s | |   q q Wd  S(   N(   t
   pytestmarkR^   R   R   R   (   R   R   t   modt   holderR   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR   y  s    R   c           B` s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s+    Collector for test classes and functions. c         C` s
   |  j    S(   N(   t   _importtestmodule(   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    c         C` s&   |  j  j j |   t t |   j   S(   N(   Rw   R   t   parsefactoriest   superR   R   (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    c         C` s  |  j  j d  } y |  j j d |  } WnWt k
 rb |  j t j j   j	 d d    n#|  j j
 k
 r t j   d } |  j d | j   n t k
 rNd d l m } |   } |  j  j d	  d
 k  r | j j t  | _ n  | j r| j	 d d  n	 | j   } t |  } |  j d j d |  j d |    n7 t j j k
 r} | j rr  n  |  j d   n X|  j  j j |  | S(   Ns   --import-modet   ensuresyspatht   stylet   shorti   s   import file mismatch:
imported module %r has this __file__ attribute:
  %s
which is not the same as the test file we want to collect:
  %s
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modulesi    (   t   ExceptionInfot   verbosei   s   ImportError while importing test module '{fspath}'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
{traceback}R   t	   tracebacks   Using pytest.skip outside of a test is not allowed. If you are trying to decorate a test function, use the @pytest.mark.skip or @pytest.mark.skipif decorators instead.(   RT   t	   getoptionR   t   pyimportt   SyntaxErrort   CollectErrort   _pytestt   _codeR   t   getreprt   ImportMismatchErrorR   t   exc_infoRC   t   ImportErrort   _pytest._code.codeR   t   filterR*   t   exconlyR   R[   t   runnert   Skippedt   allow_module_levelt   pluginmanagert   consider_module(   R1   RL   R   t   eR   R  t   exc_reprt   formatted_tb(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s8    !	'		c         C` s   t  |  j d  } | d  k r3 t  |  j d  } n  | d  k	 rI |   n  t  |  j d  } | d  k r| t  |  j d  } n  | d  k	 r |  j |  n  d  S(   Nt   setUpModulet   setup_modulet   tearDownModulet   teardown_module(   t   _get_xunit_setup_teardownR0   R/   t   addfinalizer(   R1   R  R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   setup  s    
(   R\   R   t   __doc__R   R   R   R  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s
   			,c         ` s|     d k	 r   n |    t |  |    d k	 rx  j j } t j   r[ | d 8} n  | rq    f d   S Sn  d S(   s^  
    Return a callable to perform xunit-style setup or teardown if
    the function exists in the ``holder`` object.
    The ``param_obj`` parameter is the parameter which will be passed to the function
    when the callable is called without arguments, defaults to the ``holder`` object.
    Return ``None`` if a suitable callable is not found.
    i   c           ` s
       S(   N(    (    (   t	   param_objt   result(    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    N(   R/   t   _get_xunit_funct   __code__t   co_argcountR   t   ismethod(   R   t	   attr_nameR  t	   arg_count(    (   R  R  s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s    c         C` s/   t  |  | d  } t j |  d k r+ | Sd S(   s   Return the attribute from the given object to be used as a setup/teardown
    xunit-style function, but only if not marked as a fixture to
    avoid calling it twice.
    N(   R-   R/   R   R   (   R0   R3   t   meth(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s    R   c           B` s    e  Z d  Z d   Z d   Z RS(   s    Collector for test methods. c         C` s   t  |  j d t  s g  St |  j  rF |  j d d |  j j  g  St |  j  rs |  j d d |  j j  g  S|  j d  d d d |   g S(	   NR   t   C1sB   cannot collect test class %r because it has a __init__ constructorsA   cannot collect test class %r because it has a __new__ constructorR   R3   s   ()Ru   (   R   R0   Ro   t   hasinitR   R\   t   hasnewR   (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    c         ` s   t   j d  } | d  k	 rR t | d |  } t | d |  } |  j  n  t  j d d       d  k	 r t   d      t   d       j    f d    n  d  S(   Nt   setup_classt   im_funcR   t   teardown_classc           ` s      j   S(   N(   R0   (    (   t	   fin_classR1   (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    (   R  R0   R/   R-   R  (   R1   R'  (    (   R*  R1   s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s    (   R\   R   R  R   R  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s   	R   c           B` s#   e  Z d    Z d   Z d   Z RS(   c         C` s   |  j  j   S(   N(   Ru   R0   (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR   	  s    c         C` s&   |  j  j j |   t t |   j   S(   N(   Rw   R   R   R   R   R   (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    c         C` s   |  j    |  _ |  j S(   N(   R   R0   (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   newinstance  s    (   R\   R   R   R   R+  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s   		t   FunctionMixinc           B` s8   e  Z d  Z d   Z d   Z d d  Z d d  Z RS(   s:    mixin for the code common to Function and Generator.
    c         C` s   t  |  d  r |  j } n? t |  j t  rN |  j j   } |  j   |  _ n |  j j } t j	 |  j  r{ d } d } n d } d } t
 | | d |  j } | d k	 r |   n  t
 | | d |  j } | d k	 r |  j |  n  d S(   s'    perform setup for this test function. t   _preservedparentt   setup_methodt   teardown_methodt   setup_functiont   teardown_functionR  N(   RY   R-  R   Ru   R   R+  R   R0   R   R   R  R/   R  (   R1   R0   t
   setup_namet   teardown_namet   setup_func_or_methodt   teardown_func_or_method(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s"    	
c         C` s*  t  |  d  r&|  j j j r&t j j t |  j   } | j	 | j
 } } | j } | j d | d |  } | | k r | j d |  } | | k r | j t  } | s | } q q n  | j   | _ |  j j j d k r&t | j  d k r#x( | j d d !D] } | j d  qWq#q&n  d  S(	   NR   R    t   firstlinenot   autoi   i   iR   (   RY   RT   RS   t	   fulltraceR  R  t   CodeR   R0   R    R6  R   t   cutR	  R*   t   tbstylet   lent   set_repr_style(   R1   t   excinfoR   R    R6  R   t
   ntracebackR&   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   _prunetraceback.  s     	t   longc         C` sP   | j  t j  r4 | j j s4 t j j | j  Sn  t t	 |   j
 | d | S(   NR   (   t   errisinstanceR   t	   ExceptionR   t   pytraceR   t   _builtint   _totextR   R,  t   _repr_failure_py(   R1   R>  R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyRG  D  s
    c         C` sO   | d  k s t d   |  j j j } | d k r< d } n  |  j | d | S(   Ns   XXX outerr usage is deprecatedR7  RA  R   (   R/   R   RT   RS   R;  RG  (   R1   R>  t   outerrR   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   repr_failureK  s
    	N(   R\   R   R  R  R@  RG  R/   RI  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR,    s
   		R   c           B` s   e  Z d    Z d   Z RS(   c   	   	   C` s;  d d l  m } |  j j j |   |  j j |  _ g  } i  } x t |  j    D] \ } } |  j	 |  \ } } } t
 |  s t d |  j | f   n  | d  k r d | } n
 d | } | | k r t d |  | f   n  t | | <| j |  j | |  d | d |  |  j j d	 | j d
 |  j qQ W| S(   Ni    (   t
   deprecateds   %r yielded non callable test %rs   [%d]s   ['%s']s*   %r generated tests with non-unique name %rRC   R   R$  t
   fslocation(   R  RJ  Rw   t   _setupstatet   prepareRu   R0   R-  t	   enumeratet   getcallargst   callablet	   TypeErrorR/   t
   ValueErrorRo   RK   R   RT   R   t   YIELD_TESTSR   (	   R1   RJ  R   R   t   it   xR3   t   callRC   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR   T  s$    

%#c         C` sy   t  | t t f  s! | f } n  t  | d t j j  rQ | d } | d } n d  } | d | d } } | | | f S(   Ni    i   (   R   t   tupleR   R   t   builtint   _basestringR/   (   R1   R0   R3   RV  RC   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyRO  m  s    
(   R\   R   R   RO  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR   S  s   	c         C` s)   t  |  d d   } | r% | t j k Sd  S(   Nt   __init__(   R-   R/   t   objectRZ  (   R0   t   init(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR%  z  s    c         C` s)   t  |  d d   } | r% | t j k Sd  S(   Nt   __new__(   R-   R/   R[  R]  (   R0   t   new(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR&    s    t	   CallSpec2c           B` sM   e  Z d    Z d   Z d   Z d   Z e d    Z d   Z d   Z	 RS(   c         C` sa   | |  _  i  |  _ g  |  _ i  |  _ t |  _ t   |  _ t |  _ i  |  _	 i  |  _
 i  |  _ d  S(   N(   R`   Rl   t   _idlistt   paramsR   t	   _globalidt   sett   _globalid_argst   _globalparamt   _arg2scopenumR   t   indices(   R1   R`   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyRZ    s    								c         C` s   t  |  j  } | j j |  j  | j j |  j  | j j |  j  | j j |  j  | j j |  j  t |  j	  | _	 |  j
 | _
 |  j | _ |  j | _ | S(   N(   R_  R`   Rl   t   updateRa  R   Rg  Rf  R   R`  Rb  Rd  Re  (   R1   R`   t   cs(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   copy  s    c         C` s8   | |  j  k s | |  j k r4 t d | f   n  d  S(   Ns   duplicate %r(   Ra  Rl   RR  (   R1   Rs   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   _checkargnotcontained  s    c         C` sI   y |  j  | SWn3 t k
 rD |  j t k r= t |   n  |  j SXd  S(   N(   Ra  t   KeyErrorRe  R   RR  (   R1   R3   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   getparam  s    c         C` s"   d j  t t t d  |  j    S(   Nt   -(   R   t   mapt   strR	  R/   R`  (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    c         C` s   xa t  | |  D]P \ } }	 |  j |  | | }
 |	 t |  |
  | <| |  j | <| |  j | <q W|  j j |  |  j j |  d  S(   N(	   t   zipRk  R-   Rg  Rf  R`  RK   R   Rh  (   R1   t   valtypesRn   t   valsetR   R   t   scopenumt   param_indexRs   R   t   valtype_for_arg(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   setmulti  s    
c         C` s   x | D] } |  j  |  q W|  j j |  | t k	 rM |  j j |  n  | t k	 rz |  j t k sn t  | |  _ n  x | D] } t j	 |  j
 | <q Wd  S(   N(   Rk  Rl   Rh  R   R`  RK   Re  R   R   t   scopenum_functionRf  (   R1   Rl   R   t   paramRU  Rs   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   setall  s    (
   R\   R   RZ  Rj  Rk  Rm  R6   R   Rw  Rz  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR_    s   					R   c           B` sA   e  Z d  Z d d d  Z e d d d  Z d e e d  Z RS(   s   
    Metafunc objects are passed to the ``pytest_generate_tests`` hook.
    They help to inspect a test function and to generate tests according to
    test configuration or values specified in the class or module where a
    test function is defined.
    c         C` s[   | |  _  | |  _ | |  _ | j |  _ | |  _ g  |  _ t j j	   |  _
 | j |  _ d  S(   N(   RT   R   RZ   t   names_closuret   fixturenamesR   R   R   RX  Rc  t   _idst   name2fixturedefst   _arg2fixturedefs(   R1   RZ   R   RT   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyRZ    s    					c      
   C` s}  d d l  m } d d l m } m } d d l m }	 t | t t	 f  s g  | j
 d  D] }
 |
 j   r[ |
 j   ^ q[ } t |  d k } n t } g  | D] }
 | j |
 d | ^ q } ~ | sCt |  j  \ } } d | |  j j | | f } | j d	 |  } | j | d
 t f t |  d | g d d   n  | d k rgt | |  j |  } n  | | d d j |  j  } i  } x~ | D]v } | |  j k rt | t t	 f  r| | k rd n d } n | rd n d } t d |  j | | f   qqW| t k r-t j | d  } n | t k rNt j | d  } nm t | t t	 f  rt j | d  } xC | D]8 } | | k rt d |  j | f   n  d | | <q|Wn  d } t |  r| } d } n  | rt |  t |  k rt d t |  t |  f   n  xa | D]V } | d k	 r&t | t  j! j"  r&d } t | |	 |  t# |  j f   q&q&Wn  t$ | | | | |  j%  } g  } x |  j& pt' |   g D] } t( | | t)    } x | D] \ } } } t | j*  t |  k r't d j | j* |    n  | j+ |   } | j, | | | j* | | j- | |  | j |  qWqW| |  _& d S(   s   Add new invocations to the underlying test function using the list
        of argvalues for the given argnames.  Parametrization is performed
        during the collection phase.  If you need to setup expensive resources
        see about setting indirect to do it rather at test setup time.

        :arg argnames: a comma-separated string denoting one or more argument
                       names, or a list/tuple of argument strings.

        :arg argvalues: The list of argvalues determines how often a
            test is invoked with different argument values.  If only one
            argname was specified argvalues is a list of values.  If N
            argnames were specified, argvalues must be a list of N-tuples,
            where each tuple-element specifies a value for its respective
            argname.

        :arg indirect: The list of argnames or boolean. A list of arguments'
            names (subset of argnames). If True the list contains all names from
            the argnames. Each argvalue corresponding to an argname in this list will
            be passed as request.param to its respective argname fixture
            function so that it can perform more expensive setups during the
            setup phase of a test rather than at collection time.

        :arg ids: list of string ids, or a callable.
            If strings, each is corresponding to the argvalues so that they are
            part of the test id. If None is given as id of specific test, the
            automatically generated id for that argument will be used.
            If callable, it should take one argument (a single argvalue) and return
            a string or return None. If None, the automatically generated id for that
            argument will be used.
            If no ids are provided they will be generated automatically from
            the argvalues.

        :arg scope: if specified it denotes the scope of the parameters.
            The scope is used for grouping tests by parameter instances.
            It will also override any fixture-function defined scope, allowing
            to set a dynamic scope using test context or configuration.
        i    (   t   scope2index(   t   MARK_GENt   ParameterSet(   t   safereprt   ,i   t   legacy_force_tuples0   got empty parameter set %r, function %s at %s:%dt   reasont   valuest   marksR   t   descrs   call to {0}t   fixturet   arguments   %r uses no %s %rRa  Rl   s.   indirect given to %r: fixture %r doesn't exists   %d tests specified with %d idss1   ids must be list of strings, found: %s (type: %s)sV   In "parametrize" the number of values ({0}) must be equal to the number of names ({1})N(.   t   _pytest.fixturesR  t   _pytest.markR  R  t   py.ioR  R   RW  R   t   splitt   stripR<  R   t   extract_fromR   RZ   R\   t   skipRK   R   R/   t   _find_parametrized_scopeR  R[   R]   R|  RR  Ro   R   t   fromkeysRP  R   RX  RY  RB   t   idmakerRT   R   R_  Rq  R   R  Rj  Rw  t   deprecated_arg_dict(   R1   Rn   t	   argvaluest   indirectt   idst   scopeR  R  R  R  RU  t   force_tuplet
   parameterst   fsR   R  R   Rt  Rr  Rs   R3   t   idfnt   id_valueRc   t   newcallsR   t   elementst   a_idRy  Ru  t   newcallspec(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR]     s    '4%		"/c         C` s  | d k s! t | t  s! t  | d k	 ra x7 | D]& } | |  j k r4 t d |  q4 q4 Wn i  } | d k r t d   n  | t k r t |  j	  } n  t
 |  } | |  j k r t d |   n  |  j j |  t |   } | j | | |  |  j	 j |  d S(   s   (deprecated, use parametrize) Add a new call to the underlying
        test function during the collection phase of a test run.  Note that
        request.addcall() is called during the test collection phase prior and
        independently to actual test execution.  You should only use addcall()
        if you need to specify multiple arguments of a test function.

        :arg funcargs: argument keyword dictionary used when invoking
            the test function.

        :arg id: used for reporting and identification purposes.  If you
            don't supply an `id` an automatic unique id will be generated.

        :arg param: a parameter which will be exposed to a later fixture function
            invocation through the ``request.param`` attribute.
        s%   funcarg %r not used in this function.s   id=None not alloweds   duplicate id %rN(   R/   R   R   R   R|  R   RR  R   R<  R   Rp  R}  t   addR_  Rz  RK   (   R1   Rl   R   Ry  R3   Ri  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   addcallY  s"    !N(	   R\   R   R  R/   RZ  R   R]   R   R  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s
   uc         C` s   d d l  m } t | t t f  } | t k pF | oF t |  |  k } | r | pX i  } g  | j   D] \ } } | d j ^ qh }	 |	 r x' t	 |  D] }
 |
 |	 k r |
 Sq Wq n  d S(   s}  Find the most appropriate scope for a parametrized call based on its arguments.

    When there's at least one direct argument, always use "function" scope.

    When a test function is parametrized and all its arguments are indirect
    (e.g. fixtures), return the most narrow scope based on the fixtures used.

    Related to issue #1832, based on code posted by @Kingdread.
    i    (   t   scopesRZ   (
   R  R  R   R   RW  Ro   R<  R   R  t   reversed(   Rn   t   arg2fixturedefsR  R  t   indirect_as_listt   all_arguments_are_fixturest   fixturedefsR3   t
   fixturedeft   used_scopesR  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR  ~  s    
,c   	      C` se  | ry d  } y | |   } WnG t k
 re d d  l } d | | f } | d 7} | j | t  n X| ry t |  Sn  | r | j j d | d |  d |  } | r | Sn  t |  t	  r t |   St |  t
 t t t f  r t |   St |  t  rt |  j  St d  k	 r/t |  t j  r/t |   St |   rQt |  d  rQ|  j St |  t |  S(   Ni    sC   Raised while trying to determine id of parameter %s at position %d.s<   
Update your code as this will raise an error in pytest-4.0.RT   R   R   R\   (   R/   RC  t   warningsR   t   DeprecationWarningR   t   hookR   R   R   t   floatR   t   boolR   Rp  R   t   patternR   t   EnumR   RY   R\   (	   R   R   t   idxR  RT   R   R  Rc   t   hook_id(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   _idval  s6    



c   	      C` s   | j  d  k	 r | j  S| d  k sD |  t |  k sD | |  d  k r g  t | j |  D]$ \ } } t | | |  | |  ^ qW } d j |  St | |   Sd  S(   NRn  (   R   R/   R<  Rq  R  R  R   R   (	   R  t   parametersetRn   R  R  RT   R   R   t   this_id(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt	   _idvalset  s    .:c      	   C` s   g  t  |  D]' \ } } t | | |  | | |  ^ q } t t |   t |  k r g  | D]! } | j |  d k r_ | ^ q_ } t j d    }	 xT t  |  D]C \ }
 } | | k r | t |	 |  | |
 <|	 | c d 7<q q Wn  | S(   Ni   c           S` s   d S(   Ni    (    (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    (   RN  R  R<  Rc  R   t   collectionst   defaultdictRp  (   Rn   t   parametersetsR  R  RT   t   valindexR  t   testidt
   duplicatest   counterst   index(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s    7.c         C` s   d d l  m } | |  t  S(   Ni    (   t   wrap_session(   t   _pytest.mainR  t   _show_fixtures_per_test(   RT   R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR@     s    c         ` s   d d  l  } | j   t j j     | j j |    |  j d     f d       f d       f d   } x | j D] } | |  q Wd  S(   Ni    R   c         ` s   t  |     }   j |  S(   N(   R   t   bestrelpath(   R   t   loc(   t   curdir(    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   get_best_rel  s    c         ` s   |  j  }  d k r( | j d  r( d  S d k rX   |  j  } d j | |  } n | }  j | d t d } |  j j } | r xX | j   j d  D]" }  j | j | j     q Wn  j | j d  d t d  S(	   Ni    t   _s
   {0} -- {1}t   greens       {0}s   
s   no docstring availablet   red(	   R   R   R   R[   t   lineRo   R  R  R  (   t   fixture_defR   t   bestrelt   funcargspect   INDENTt   fixture_docR  (   R  t   twR   (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   write_fixture  s    	#c         ` s   |  j  j } | s d  S  |  j  }  j    j d d j |  j    j d d j |   xL t | j    D]8 \ } } | d  k	 s t
  | s qw n   | d  qw Wd  S(   NRn  s   fixtures used by {0}s   ({0})i(   Rm   R~  RZ   R  t   sepR[   R3   t   sortedR   R/   R   (   R   R~  R  R   t   fixture_defs(   R  R  R  (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt
   write_item  s    
(	   t   _pytest.configt   perform_collectR   R    R!   RT   t   create_terminal_writert   getvalueR   (   RT   Rw   R  R  R   (    (   R  R  R  R   R  s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s    
c         C` s   d d l  m } | |  t  S(   Ni    (   R  (   R  R  t   _showfixtures_main(   RT   R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR=     s    c         C` s{  d d  l  } | j   t j j   } | j j |   } |  j d  } | j } g  } t	   } x | j
 j   D] \ }	 }
 |
 d  k	 s t  |
 s qn n  x |
 D] } t | j |  } | j | f | k r q n  | j | j | f  | j t | j  | j j | j |  | j | f  q Wqn W| j   d  } x=| D]5\ } } } }	 } | | k r| j d  s| j   | j d d | f  | } qn  | d k r|	 d d k rq>n  | d k rd |	 | f } n |	 } | j | d t t | j |  } | j j pd	 } | rYxQ | j   j d
  D] } | j d | j    q5Wq>| j d | f d t q>Wd  S(   Ni    R   s   _pytest.Rn  s   fixtures defined from %sR  s   %s -- %sR  t    s   
s       s       %s: no docstring availableR  (   R  R  R   R    R!   RT   R  R  R   Rc  R  R   R/   R   R   R   R   R  RK   R<  t   baseidR   R  R   R   R  R  Ro   R  R  R  (   RT   Rw   R  R  R  R   R   t	   availableR   R   R  R  R  t   currentmoduleR  R   R  R  R7   R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    sT    
			

c         O` s  t  } d } t |  t  rT x[ |  D]+ } t |  s" t | t |    q" q" Wn% t |   sy t | t |     n  d j |   } d } | s d | k r | j d  } n  d | k r | j d  } | d j |  7} n  t	 |  | |  St | d t
  r| \ } t | t
  s$t  t j d  }	 |	 j j   }
 |
 j |  y5 t j j |  j   } t j j | |	 j |
  Wq|  k
 rt j j   SXn= | d } y | | d |   Wn |  k
 rt j j   SXt |  d S(	   s  
    Assert that a code block/function call raises ``expected_exception``
    and raise a failure exception otherwise.

    This helper produces a ``ExceptionInfo()`` object (see below).

    If using Python 2.5 or above, you may use this function as a
    context manager::

        >>> with raises(ZeroDivisionError):
        ...    1/0

    .. versionchanged:: 2.10

    In the context manager form you may use the keyword argument
    ``message`` to specify a custom failure message::

        >>> with raises(ZeroDivisionError, message="Expecting ZeroDivisionError"):
        ...    pass
        Traceback (most recent call last):
          ...
        Failed: Expecting ZeroDivisionError


    .. note::

       When using ``pytest.raises`` as a context manager, it's worthwhile to
       note that normal context manager rules apply and that the exception
       raised *must* be the final line in the scope of the context manager.
       Lines of code after that, within the scope of the context manager will
       not be executed. For example::

           >>> value = 15
           >>> with raises(ValueError) as exc_info:
           ...     if value > 10:
           ...         raise ValueError("value must be <= 10")
           ...     assert exc_info.type == ValueError  # this will not execute

       Instead, the following approach must be taken (note the difference in
       scope)::

           >>> with raises(ValueError) as exc_info:
           ...     if value > 10:
           ...         raise ValueError("value must be <= 10")
           ...
           >>> assert exc_info.type == ValueError

    Or you can use the keyword argument ``match`` to assert that the
    exception matches a text or regex::

        >>> with raises(ValueError, match='must be 0 or None'):
        ...     raise ValueError("value must be 0 or None")

        >>> with raises(ValueError, match=r'must be \d+$'):
        ...     raise ValueError("value must be 42")


    Or you can specify a callable by passing a to-be-called lambda::

        >>> raises(ZeroDivisionError, lambda: 1/0)
        <ExceptionInfo ...>

    or you can specify an arbitrary callable with arguments::

        >>> def f(x): return 1/x
        ...
        >>> raises(ZeroDivisionError, f, 0)
        <ExceptionInfo ...>
        >>> raises(ZeroDivisionError, f, x=0)
        <ExceptionInfo ...>

    A third possibility is to use a string to be executed::

        >>> raises(ZeroDivisionError, "f(0)")
        <ExceptionInfo ...>

    .. autoclass:: _pytest._code.ExceptionInfo
        :members:

    .. note::
        Similar to caught exception objects in Python, explicitly clearing
        local references to returned ``ExceptionInfo`` objects can
        help the Python interpreter speed up its garbage collection.

        Clearing those references breaks a reference cycle
        (``ExceptionInfo`` --> caught exception --> frame stack raising
        the exception --> current frame stack --> local variables -->
        ``ExceptionInfo``) which makes Python keep all objects referenced
        from that cycle (including all local variables in the current
        frame) alive until the next cyclic garbage collection run. See the
        official Python ``try`` statement documentation for more detailed
        information.

    sJ   exceptions must be old-style classes or derived from BaseException, not %ss   DID NOT RAISE {0}R   t   matchs    matching '{0}'i    i   N(   Ro   R   RW  R   RQ  RB   R[   R/   t   popt   RaisesContextRp  R   R   t	   _getframet   f_localsRj  Rh  R  R  t   Sourcet   compileR   RX  t   exec_t	   f_globalsR   R   (   t   expected_exceptionRC   R_   t   __tracebackhide__Rc   t   excR   t
   match_exprR   R   R  R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   raisesH  sD    _ 	
R  c           B` s#   e  Z d    Z d   Z d   Z RS(   c         C` s(   | |  _  | |  _ | |  _ d  |  _ d  S(   N(   R  R   R  R/   R>  (   R1   R  R   R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyRZ    s    			c         C` s   t  j t j j  |  _ |  j S(   N(   R[  R]  R  R  R   R>  (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt	   __enter__  s    c         G` s   t  } | d d  k r& t |  j  n  t j d k  rr t | d t  sr | \ } } } | | |  | f } qr n  |  j j	 |  t
 |  j j |  j  } t j d d k r | r t j   n  |  j r |  j j |  j  n  | S(   Ni    i   i   i   (   i   i   (   Ro   R/   R   R   R   t   version_infoR   t   BaseExceptionR>  RZ  t
   issubclassRB   R  t	   exc_clearR  R  (   R1   t   tpR  t   exc_typeR   R   t   suppress_exception(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   __exit__  s    	(   R\   R   RZ  R  R  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s   		t   approxc           B` s_   e  Z d  Z d d d  Z d   Z d   Z d Z d   Z e	 d    Z
 e
 j d    Z
 RS(   s[  
    Assert that two numbers (or two sets of numbers) are equal to each other
    within some tolerance.

    Due to the `intricacies of floating-point arithmetic`__, numbers that we
    would intuitively expect to be equal are not always so::

        >>> 0.1 + 0.2 == 0.3
        False

    __ https://docs.python.org/3/tutorial/floatingpoint.html

    This problem is commonly encountered when writing tests, e.g. when making
    sure that floating-point values are what you expect them to be.  One way to
    deal with this problem is to assert that two floating-point numbers are
    equal to within some appropriate tolerance::

        >>> abs((0.1 + 0.2) - 0.3) < 1e-6
        True

    However, comparisons like this are tedious to write and difficult to
    understand.  Furthermore, absolute comparisons like the one above are
    usually discouraged because there's no tolerance that works well for all
    situations.  ``1e-6`` is good for numbers around ``1``, but too small for
    very big numbers and too big for very small ones.  It's better to express
    the tolerance as a fraction of the expected value, but relative comparisons
    like that are even more difficult to write correctly and concisely.

    The ``approx`` class performs floating-point comparisons using a syntax
    that's as intuitive as possible::

        >>> from pytest import approx
        >>> 0.1 + 0.2 == approx(0.3)
        True

    The same syntax also works on sequences of numbers::

        >>> (0.1 + 0.2, 0.2 + 0.4) == approx((0.3, 0.6))
        True

    By default, ``approx`` considers numbers within a relative tolerance of
    ``1e-6`` (i.e. one part in a million) of its expected value to be equal.
    This treatment would lead to surprising results if the expected value was
    ``0.0``, because nothing but ``0.0`` itself is relatively close to ``0.0``.
    To handle this case less surprisingly, ``approx`` also considers numbers
    within an absolute tolerance of ``1e-12`` of its expected value to be
    equal.  Infinite numbers are another special case.  They are only
    considered equal to themselves, regardless of the relative tolerance.  Both
    the relative and absolute tolerances can be changed by passing arguments to
    the ``approx`` constructor::

        >>> 1.0001 == approx(1)
        False
        >>> 1.0001 == approx(1, rel=1e-3)
        True
        >>> 1.0001 == approx(1, abs=1e-3)
        True

    If you specify ``abs`` but not ``rel``, the comparison will not consider
    the relative tolerance at all.  In other words, two numbers that are within
    the default relative tolerance of ``1e-6`` will still be considered unequal
    if they exceed the specified absolute tolerance.  If you specify both
    ``abs`` and ``rel``, the numbers will be considered equal if either
    tolerance is met::

        >>> 1 + 1e-8 == approx(1)
        True
        >>> 1 + 1e-8 == approx(1, abs=1e-12)
        False
        >>> 1 + 1e-8 == approx(1, rel=1e-6, abs=1e-12)
        True

    If you're thinking about using ``approx``, then you might want to know how
    it compares to other good ways of comparing floating-point numbers.  All of
    these algorithms are based on relative and absolute tolerances and should
    agree for the most part, but they do have meaningful differences:

    - ``math.isclose(a, b, rel_tol=1e-9, abs_tol=0.0)``:  True if the relative
      tolerance is met w.r.t. either ``a`` or ``b`` or if the absolute
      tolerance is met.  Because the relative tolerance is calculated w.r.t.
      both ``a`` and ``b``, this test is symmetric (i.e.  neither ``a`` nor
      ``b`` is a "reference value").  You have to specify an absolute tolerance
      if you want to compare to ``0.0`` because there is no tolerance by
      default.  Only available in python>=3.5.  `More information...`__

      __ https://docs.python.org/3/library/math.html#math.isclose

    - ``numpy.isclose(a, b, rtol=1e-5, atol=1e-8)``: True if the difference
      between ``a`` and ``b`` is less that the sum of the relative tolerance
      w.r.t. ``b`` and the absolute tolerance.  Because the relative tolerance
      is only calculated w.r.t. ``b``, this test is asymmetric and you can
      think of ``b`` as the reference value.  Support for comparing sequences
      is provided by ``numpy.allclose``.  `More information...`__

      __ http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.isclose.html

    - ``unittest.TestCase.assertAlmostEqual(a, b)``: True if ``a`` and ``b``
      are within an absolute tolerance of ``1e-7``.  No relative tolerance is
      considered and the absolute tolerance cannot be changed, so this function
      is not appropriate for very large or very small numbers.  Also, it's only
      available in subclasses of ``unittest.TestCase`` and it's ugly because it
      doesn't follow PEP8.  `More information...`__

      __ https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertAlmostEqual

    - ``a == pytest.approx(b, rel=1e-6, abs=1e-12)``: True if the relative
      tolerance is met w.r.t. ``b`` or if the absolute tolerance is met.
      Because the relative tolerance is only calculated w.r.t. ``b``, this test
      is asymmetric and you can think of ``b`` as the reference value.  In the
      special case that you explicitly specify an absolute tolerance but not a
      relative tolerance, only the absolute tolerance is considered.
    c         C` s   | |  _  | |  _ | |  _ d  S(   N(   t   expectedt   abst   rel(   R1   R  R  R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyRZ  h  s    		c         C` s   d j  d   |  j D  S(   Ns   , c         s` s   |  ] } t  |  Vq d  S(   N(   t   repr(   t   .0RU  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pys	   <genexpr>n  s    (   R   R  (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   __repr__m  s    c         C` sj   d d l  m } t | |  s+ | g } n  t |  t |  j  k rJ t St d   t | |  j  D  S(   Ni    (   t   Iterablec         s` s!   |  ] \ } } | | k Vq d  S(   N(    (   R  t   aRU  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pys	   <genexpr>v  s    (   R  R   R   R<  R  R   t   allRq  (   R1   t   actualR   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   __eq__p  s    c         C` s   | |  k S(   N(    (   R1   R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   __ne__z  s    c         ` se   d d l  m }   f d   } t   j |  rQ g    j D] } | |  ^ q; S|   j  g Sd  S(   Ni    (   R   c         ` s   t  |    j   j  S(   N(   t   ApproxNonIterableR  R  (   RU  (   R1   (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    (   R  R   R   t	   _expected(   R1   R   t   approx_non_iterRU  (    (   R1   s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR  }  s
     c         C` s   | |  _  d  S(   N(   R  (   R1   R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s    N(   R\   R   R  R/   RZ  R  R  t   __hash__R  R6   R  t   setter(    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s   p			R  c           B` sM   e  Z d  Z d d d  Z d   Z d   Z d Z d   Z e	 d    Z
 RS(   s5  
    Perform approximate comparisons for single numbers only.

    In other words, the ``expected`` attribute for objects of this class must
    be some sort of number.  This is in contrast to the ``approx`` class, where
    the ``expected`` attribute can either be a number of a sequence of numbers.
    This class is responsible for making comparisons, while ``approx`` is
    responsible for abstracting the difference between numbers and sequences of
    numbers.  Although this class can stand on its own, it's only meant to be
    used within ``approx``.
    c         C` s   | |  _  | |  _ | |  _ d  S(   N(   R  R  R  (   R1   R  R  R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyRZ    s    		c         C` s   t  |  j t  r t |  j  St j |  j  r> t |  j  Sy d j |  j  } Wn t k
 rm d } n Xt	 j
 d d k r d j |  j |  Sd j |  j |  Sd  S(   Ns   {:.1e}s   ???i    i   s
   {0} +- {1}u
   {0} ± {1}(   R   R  t   complexRp  t   matht   isinfR[   t	   toleranceRR  R   R  (   R1   t   vetted_tolerance(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s    
c         C` sI   | |  j  k r t St j t |  j    r/ t St |  j  |  |  j k S(   N(   R  Ro   R  R  R  R   R  (   R1   R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s
    c         C` s   | |  k S(   N(    (   R1   R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s    c         C` s   d   } | |  j  d  } | d k  r? t d j |    n  t j |  r] t d   n  |  j d  k r |  j  d  k	 r | Sn  | |  j d  t  |  j  } | d k  r t d j |    n  t j |  r t d   n  t | |  S(	   Nc         S` s   |  d  k	 r |  S| S(   N(   R/   (   RU  R>   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s    g-q=i    s(   absolute tolerance can't be negative: {}s    absolute tolerance can't be NaN.gư>s(   relative tolerance can't be negative: {}s    relative tolerance can't be NaN.(	   R  RR  R[   R  t   isnanR  R/   R  t   max(   R1   t   set_defaultt   absolute_tolerancet   relative_tolerance(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s    	N(   R\   R   R  R/   RZ  R  R  R	  R  R6   R  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s   			R   c        	   B` s   e  Z d  Z d	 Z d	 d	 d	 e d	 d	 d	 d	 d  Z d   Z e d    Z	 d   Z
 e d    Z d   Z d   Z d   Z RS(
   s]    a Function Item is responsible for setting up and executing a
    Python test function.
    c         C` s  t  t |   j | | d | d | | |  _ | t k	 rF | |  _ n  |  j j |  j j  | r | |  _	 |  j j | j  n  | r |  j j |  n  |	 d  k r |  j j j |  j |  j |  j d |  j   }	 n  |	 |  _ |	 j |  _ |  j   |
 |  _ d  S(   NRT   Rw   Rl   (   R   R   RZ  Rk   R   R0   R   Rh  R   R   R/   Rw   R   R   Ru   R   Rj   Rm   R{  R|  t   _initrequestR   (   R1   R3   Ru   RC   RT   R   R   R   Rw   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyRZ    s&    			
c         C` s   i  |  _  |  j   r4 t |  d  s t d   nU t |  d  r |  j } | j  s\ t  | j |  _ t | d  r | j |  _ q n  t j	 |   |  _
 d  S(   NR   s3   yielded functions (deprecated) cannot have funcargsRy  (   Rl   Rj   RY   R   R   R   t   _genidRy  R   t   FixtureRequestt   _request(   R1   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR    s    		c         C` s   t  |  j d |  j  S(   s#   underlying python 'function' objectR(  (   R-   R0   (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyRZ   #  s    c         C` sD   |  j  } | j d  } | d k r1 | |  } n  t |  j j |  S(   NR   i(   R3   t   findR-   Ru   R0   (   R1   R3   RT  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR   (  s
    	c         C` s   |  S(   s@   (compatonly) for code expecting pytest-2.2 style request objects(    (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   _pyfuncitem/  s    c         C` s   t  |  d d   d  k	 S(   NRk   (   R-   R/   (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyRj   4  s    c         C` s   |  j  j d |   d S(   s'    execute the underlying test function. Rp   N(   R~   Rt   (   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   runtest7  s    c         C` s$   t  t |   j   t j |   d  S(   N(   R   R   R  R   t   fillfixtures(   R1   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR  ;  s    N(   R\   R   R  R/   R  R   RZ  R  R6   RZ   R   R  Rj   R  R  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyR     s   				(a   R  t
   __future__R    R   R   Rz   R   R   R   R  R  t	   itertoolsR   R   R  R   R  R   R  t   _pytest._pluggyt   _pluggyt   pluggyR   R   t   _pytest.compatR   R	   R
   R   R   R   R   R   R   R   R   R   R   R   t   _pytest.runnerR   R    R!   R   t   rstripR"   t   dirpathR$   R%   R*   R8   RR   RU   Rf   Rh   Ro   Rt   R   R|   R   R/   R   R[  R   R   t	   CollectorR   R   R   t   FileR   R  R  R   R   R,  R   R%  R&  R_  t   FuncargnamesCompatAttrR   R  R  R  R  R@   R  R=   R  R  RC  R  R  R  t   ItemR   (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/python.pyt   <module>   sz   ^		
							9m		D	
?'		B	!		7		5	!d