
i\c           @` s  d  d l  m Z d  d l  m Z d  d l  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	 m
 Z
 d  d l	 m Z d  d l	 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 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  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) e j* d e+  d e, f d     Y Z- d    Z. i  Z/ e0 d! f   Z1 d" f e1 d# <d" d$ f e1 d$ <e1 d$ d% f e1 d& <e1 d& d' f e1 d' <e1 d' d( d) f e1 d( <e2 e2 d*  Z3 d+   Z4 d,   Z5 d-   Z6 d.   Z7 d/   Z8 d0   Z9 d1   Z: d2   Z; d3   Z< d4   Z= e j* d5 e+  d6 e, f d7     Y Z> d8 e f d9     YZ? d: e? f d;     YZ@ d< jA   ZB eB jC d(  ZD d=   ZE e2 d>  ZF d? eG f d@     YZH dA e f dB     YZI dC   ZJ dD   ZK dE   ZL dF e, f dG     YZM dH   ZN dI   ZO dJ   ZP dK   ZQ e j* d e+  dL e, f dM     Y ZR d( e2 eS e2 e2 dN  ZT d( e2 eS e2 e2 dO  ZU eT   ZV eT dP d!  dQ    ZW dR   ZX dS e, f dT     YZY d S(U   i    (   t   absolute_import(   t   division(   t   print_functionN(   t   defaultdict(   t   deque(   t   OrderedDict(   t   nodes(   t   FormattedExcinfo(   t   TerminalRepr(   t   _format_args(   t   _PytestWrapper(   t	   exc_clear(   t   FuncargnamesCompatAttr(   t   get_real_func(   t   get_real_method(   t   getfslineno(   t   getfuncargnames(   t	   getimfunc(   t   getlocation(   t   is_generator(   t   isclass(   t   NOTSET(   t   safe_getattr(   t   FIXTURE_FUNCTION_CALL(   t   FIXTURE_NAMED_REQUEST(   t   fail(   t   TEST_OUTCOMEt   frozent   PseudoFixtureDefc           B` s    e  Z e j   Z e j   Z RS(    (   t   __name__t
   __module__t   attrt   ibt   cached_resultt   scope(    (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR   +   s   c         C` sy   d d  l  } d d  l } t j i | j j d 6| j j d 6| j j d 6| j j	 d 6| j
 j d 6 t |   |  _ d  S(   Ni    t   packaget   classt   modulet   functiont   session(   t   _pytest.pythont   _pytest.nodest   scopename2classt   updatet   pythont   Packaget   Classt   ModuleR   t   Itemt   maint   Sessiont   FixtureManagert   _fixturemanager(   R'   t   _pytest(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   pytest_sessionstart1   s    R'   t   fspathR#   R%   t   clsR$   t   instanceR&   t   keywordsc         ` s     f d   } | S(   Nc         ` s7    p   j      f d   } t | d  d    j  S(   Nc         ` s=     j  t |  j k r    |   St d  |  j f   d  S(   Ns%   %s not available in %s-scoped context(   R   t   scope2propsR"   t   AttributeError(   t   self(   t   funct	   scopename(    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   provideP   s    
(   R   t   propertyt   Nonet   __doc__(   R>   R@   (   t   name(   R>   R?   s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   decoratescopeM   s    (    (   RD   t   docRE   (    (   RD   s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   scopepropertyL   s    c         C` s|   d d  l  } | j } |  } d | j d f } x4 | rd t |  | k	 sX | | j k rd | j } q1 W| d  k rx |  j S| S(   Ni    s   %s/%ss   __init__.py(   t   pytestR-   t   baseidt   typet   nodeidt   parentRB   R'   (   t   nodet
   fixturedefRH   R8   t   currentt   fixture_package_name(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   get_scope_package\   s    		!c         C` s7   t  j |  } | d  k r* t d   n  |  j |  S(   Ns   unknown scope(   R*   t   getRB   t
   ValueErrort	   getparent(   RM   R"   R8   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   get_scope_nodek   s    c      
   C` s  | j  d j s d  Si  } i  } x | j  D] } x | j j   D] \ } } | | j k sa t  | | j | <| j | g   } t |  | j | <| j |  | | k r@ | j	 j
 | t  }	 t |	 | | <q@ q@ W| j j   q* W| j }
 x | j   D] \ } } | | } d  } | d k rst |  |  } | d  k rs| d k rat |  t j j  sgt  |  } qsn  | r| | j k r| j | g |
 | <q t | d | t | | | t t  } | g |
 | <| d  k	 r | | j | <q q Wd  S(   Ni    R&   R$   t    (   t   _callst   funcargst   itemst   paramst   AssertionErrort
   setdefaultt   lent   indicest   appendt   _arg2scopenumRR   t   scopenum_functiont   scopest   cleart   _arg2fixturedefsRB   RU   t
   isinstanceR5   R,   R/   t   _name2pseudofixturedeft
   FixtureDeft   get_direct_param_fixture_funct   False(   t	   collectort   metafunct   fixturemanagert
   arg2paramst	   arg2scopet   callspect   argnamet   argvaluet   arg2params_listt   scopenumt   arg2fixturedefst	   valuelistR"   RM   RN   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   add_funcarg_pseudo_fixture_defr   sL    	
'	c         C` s-   y t  |  d d  SWn t k
 r( d SXd S(   sK    return fixturemarker or None if it doesn't exist or raised
    exceptions.t   _pytestfixturefunctionN(   t   getattrRB   R   (   t   obj(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   getfixturemarker   s    c         c` s  | t  k  s t  y |  j } Wn t k
 r2 n Xx t | j j    D] \ } } | j | | k rn qI n  | d k r | | f } no | d k r | | |  j j	   f } nH | d k r | | |  j f } n' | d k r | | |  j |  j
 f } n  | VqI Wd S(   sY    return list of keys for all parametrized arguments which match
    the specified scope. i    i   i   i   N(   Ra   R[   Ro   R<   t   sortedR^   RY   R`   R7   t   dirpathR8   (   t   itemRs   t   csRp   t   param_indext   key(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   get_parametrized_fixture_keys   s"    "c   	      C` s   i  } i  } x t  d t  D] } i  | | <} t t  | | <} x[ |  D]S } t j t | |   } | rK | | | <x" | D] } | | j |  q WqK qK Wq Wt j |   }  t t	 |  | | d   S(   Ni    (
   t   rangeRa   R   R   R   t   fromkeysR   R_   t   listt   reorder_items_atscope(	   RY   t   argkeys_cachet   items_by_argkeyRs   t   dt   item_dR}   t   keysR   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   reorder_items   s    
 c         C` sT   xM t  d t  D]< } x3 | | j |  g   D] } | | | j |   q- Wq Wd  S(   Ni    (   R   Ra   RR   t
   appendleft(   R}   R   R   Rs   R   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   fix_cache_order   s    c         ` s  | t  k s t |   d k  r" |  St     t |   } t   } | | } | | } xH| rt   } d  }	 x | rP| j   }
 |
 | k so |
 | k r qo n  t j   f d   | j |
 g   D  } | s d  | |
 <qo | j	   \ }	 } g  | |	 D] } | |  k r | ^ q } x1 t
 |  D]# } t | | |  | j |  q%WPqo W| rt | | | | d  } x | D] }
 d  | |
 <qwWn    j |	  qW W| S(   Ni   c         3` s!   |  ] } |   k r | Vq d  S(   N(    (   t   .0t   k(   t   ignore(    s/   lib/python2.7/site-packages/_pytest/fixtures.pys	   <genexpr>   s    i   (   Ra   R]   t   setR   R   RB   t   popleftR   RR   t   popitemt   reversedR   R   R   t   add(   RY   R   R   Rs   t   items_dequet
   items_donet   scoped_items_by_argkeyt   scoped_argkeys_cachet   no_argkey_groupt   slicing_argkeyR}   t   argkeyst   _t   it   matching_items(    (   R   s/   lib/python2.7/site-packages/_pytest/fixtures.pyR      s>    		

			%)c         C` s   y |  j  } Wn t k
 r |  j j } | j |  j |  j d  } | |  _ t	 |   } |  _  | j
   i  } x" | j D] } |  j | | | <qz W| |  _ n X| j
   d S(   s,    fill missing funcargs for a test function. N(   t   _requestR<   R'   R4   t   getfixtureinfoRL   Ry   RB   t   _fixtureinfot   FixtureRequestt   _fillfixturest   argnamesRX   (   R&   t   requestt   fmt   fit   newfuncargsRD   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   fillfixtures  s    	
c         C` s   |  j  S(   N(   t   param(   R   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyRh   +  s    t   slotst   FuncFixtureInfoc           B` sM   e  Z e j d  e  Z e j d  e  Z e j   Z e j   Z d   Z	 RS(   RJ   c         C` s   t    } t  |  j  } xn | r | j   } | | k r | |  j k r | j |  | |  j k r | j |  j | d j  q q q Wt | d |  j j	 |  j (d S(   s  Recompute names_closure from initialnames and name2fixturedefs

        Can only reduce names_closure, which means that the new closure will
        always be a subset of the old one. The order is preserved.

        This method is needed because direct parametrization may shadow some
        of the fixtures that were included in the originally built dependency
        tree. In this way the dependency tree can get pruned, and the closure
        of argnames may get reduced.
        iR   N(
   R   t   initialnamest   popt   names_closureR   t   name2fixturedefsR+   R   R{   t   index(   R=   t   closuret   working_setRp   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   prune_dependency_tree:  s    		%(
   R   R   R   R    t   tupleR   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR   /  s
   R   c           B` sL  e  Z d  Z d   Z e d    Z e d    Z d   Z e d    Z e	   d    Z
 e	 d  d    Z e d	    Z e	   d
    Z e	   d    Z e d    Z e d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s    A request for a fixture from a test or fixture function.

    A request object gives access to the requesting test context
    and has an optional ``param`` attribute in case
    the fixture is parametrized indirectly.
    c         C` s[   | |  _  d  |  _ d |  _ i  |  _ | j } | j j   |  _ i  |  _	 | j
 j |  _ d  S(   NR&   (   t   _pyfuncitemRB   t   fixturenameR"   t   _fixture_defsR   R   t   copyRd   t
   _arg2indexR'   R4   (   R=   t
   pyfuncitemt   fixtureinfo(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   __init__^  s    						c         C` s8   t  |  j j j  } | j t |  j  j |   | S(   s,   names of all active fixtures in this request(   R   R   R   R   t   extendR   R   t
   difference(   R=   t   result(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   fixturenamesj  s    c         C` s   |  j  |  j  S(   s>    underlying collection node (depends on current request scope)(   t   _getscopeitemR"   (   R=   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyRM   q  s    c         C` s   |  j  j | d   } | d  k rU |  j j j } |  j j | |  } | |  j  | <n  |  j j | d  d } | d  k s | t	 |  k r t
 | |    n  | |  j | <| | S(   Ni    i   (   Rd   RR   RB   R   RL   RK   R4   t   getfixturedefsR   R]   t   FixtureLookupError(   R=   Rp   t   fixturedefst   parentidR   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   _getnextfixturedefv  s    c         C` s
   |  j  j S(   s8    the pytest config object associated with this request. (   R   t   config(   R=   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s    c         C` s
   |  j  j S(   s?    test function object if the request has a per-function scope. (   R   Ry   (   R=   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR&     s    R$   c         C` s)   |  j  j t j j  } | r% | j Sd S(   s<    class (can be None) where the test function was collected. N(   R   RT   R5   R,   R.   Ry   (   R=   t   clscol(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR8     s    c         C` sE   y |  j  j SWn0 t k
 r@ t |  d d  } t | d d  SXd S(   s>    instance (can be None) on which test function was collected. R&   t   __self__N(   R   t	   _testcaseR<   Rx   RB   (   R=   R&   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR9     s
    c         C` s   |  j  j t j j  j S(   s=    python module object where the test function was collected. (   R   RT   R5   R,   R/   Ry   (   R=   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR%     s    c         C` s
   |  j  j S(   sD    the file system path of the test module which collected this test. (   R   R7   (   R=   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR7     s    c         C` s
   |  j  j S(   s6    keywords/markers dictionary for the underlying node. (   RM   R:   (   R=   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR:     s    c         C` s
   |  j  j S(   s    pytest session object. (   R   R'   (   R=   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR'     s    c         C` s   |  j  | d |  j d S(   s    add finalizer/teardown function to be called after the
        last test within the requesting test context finished
        execution. R"   N(   t   _addfinalizerR"   (   R=   t	   finalizer(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   addfinalizer  s    c         C` s2   |  j  |  } |  j j j j d | d |  d  S(   NR   t   colitem(   R   R   R'   t   _setupstateR   (   R=   R   R"   R   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s    c         C` s   |  j  j |  d S(   s.   Apply a marker to a single test function invocation.
        This method is useful if you don't want to have a keyword/marker
        on all function invocations.

        :arg marker: a :py:class:`_pytest.mark.MarkDecorator` object
            created by a call to ``pytest.mark.NAME(...)``.
        N(   RM   t
   add_marker(   R=   t   marker(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   applymarker  s    c         C` s   |  j  j d |  |   d S(   s4    raise a FixtureLookupError with the given message. N(   R4   R   RB   (   R=   t   msg(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt
   raiseerror  s    c         C` s[   |  j  } t | d |  j  } x6 | D]. } | | j k r% |  j |  | j | <q% q% Wd  S(   NR   (   R   Rx   R   RX   t   getfixturevalue(   R=   R}   R   Rp   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s
    	c         C` s   |  j  |  j d S(   s;   Dynamically run a named fixture function.

        Declaring fixtures via function argument is recommended where possible.
        But if you can only decide whether to use another fixture at test
        setup time, you may use this function to retrieve it inside a fixture
        or test function body.
        i    (   t   _get_active_fixturedefR!   (   R=   Rp   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s    c         C` s3   d d l  m } t j | j d d |  j |  S(   s"    Deprecated, use getfixturevalue. i    (   t
   deprecatedt
   stackleveli   (   R5   R   t   warningst   warnt   GETFUNCARGVALUER   (   R=   Rp   R   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   getfuncargvalue  s    c         C` s   y |  j  | SWnl t k
 r} y |  j |  } Wq~ t k
 ry | d k rs |  d g d  f } d } t | |  S  q~ Xn X|  j |  | |  j  | <| S(   NR   i    R&   (   R   t   KeyErrorR   R   RB   R   t   _compute_fixture_value(   R=   Rp   RN   R!   R"   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s    c         C` sY   |  } g  } xF t  | d d   } | d  k r; | j   | S| j |  | j } q Wd  S(   Nt   _fixturedef(   Rx   RB   t   reverseR_   t   _parent_request(   R=   RO   t   valuesRN   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   _get_fixturestack  s    
c         C` s#  | j  } |  j } | j } y | j j |  } WnPt t f k
 rt } d } | j d k	 } t
 | d t  } | r | r d j d | j d | j d t |  j  }	 t |	 d t n  | rt j   d }
 t j |
 d  } | j } | j } t j j |  } | j | j j  r:| j | j j  } n  d	 j | j | j  t | j | j j  | |  }	 t |	 d t qn? X| j j | } | j j  j! |  } | d k	 rt" | } n  t# |  | | | |  } | j$ | |  j |  t%   z | j& d
 |  Wd |  j' | |  Xd S(   sL  
        Creates a SubRequest based on "self" and calls the execute method of the given fixturedef object. This will
        force the FixtureDef object to throw away any previous results and compute a new fixture value, which
        will be stored into the FixtureDef object itself.

        :param FixtureDef fixturedef:
        i    t
   nofuncargsso   {name} does not support fixtures, maybe unittest.TestCase subclass?
Node id: {nodeid}
Function type: {typename}RD   RK   t   typenamet   pytracei   s}   The requested fixture has no parameter defined for test:
    {}

Requested fixture '{}' defined in:
{}

Requested here:
{}:{}R   N((   Rp   R   R"   Ro   t   getparamR<   RS   R   RZ   RB   Rx   Ri   t   formatRD   RK   RJ   R   R   t   inspectt   stackt   getframeinfot   filenamet   linenot   pyt   patht   localt   reltoR   t   rootdirR   R>   R^   R`   RR   Rb   t
   SubRequestt   _check_scopeR   t   executet   _schedule_finalizers(   R=   RN   Rp   t   funcitemR"   R   R   t
   has_paramst   fixtures_not_supportedR   t   framet	   frameinfot   source_patht   source_linenot   paramscopenumt
   subrequest(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     sR    
									c         C` s/   |  j  j j t j | j d | | j  d  S(   NR   (   R'   R   R   t	   functoolst   partialt   finishRM   (   R=   RN   R  (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR   O  s    c         C` s[   | d k r d  St  | |  rW |  j   } t d | | | d j |  f d t n  d  S(   NR   sr   ScopeMismatch: You tried to access the %r scoped fixture %r with a %r scoped request object, involved factories
%ss   
R   (   t   scopemismatcht   _factorytracebackR   t   joinRi   (   R=   Rp   t   invoking_scopet   requested_scopet   lines(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR   U  s    c         C` s   g  } xw |  j    D]i } | j } t |  \ } } |  j j j j |  } t |  } | j d | | d | j	 | f  q W| S(   Ns   %s:%d:  def %s%si   (
   R   R>   R   R   R'   R7   t   bestrelpathR	   R_   R   (   R=   R
  RN   t   factoryt   fsR   t   pt   args(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR  c  s    	(c         C` s   | d k r |  j  S| d k r7 t |  j  |  j  } n t |  j  |  } | d  k rm | d k rm |  j  } n  | s t d j | |  j     | S(   NR&   R#   R$   s8   Could not obtain a node for scope "{}" for function {!r}(   R   RQ   R   RU   RB   R[   R   (   R=   R"   RM   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR   m  s    c         C` s   d |  j  S(   Ns   <FixtureRequest for %r>(   RM   (   R=   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   __repr__}  s    (    R   R   RC   R   RA   R   RM   R   R   RG   R&   R8   R9   R%   R7   R:   R'   R   R   R   R   R   R   R   R   R   R   R   R   R  R   R  (    (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR   V  s8   		
			
			
				J			
	R   c           B` s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   sP    a sub request for handling getting a fixture from a
    test function/fixture. c         C` s   | |  _  | j |  _ | t k	 r- | |  _ n  | |  _ | |  _ | |  _ | j |  _ | j	 |  _	 | j
 |  _
 | j |  _ | j |  _ d  S(   N(   R   Rp   R   R   R   R   R"   R   R   R   Rd   R   R4   (   R=   R   R"   R   R   RN   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s    				c         C` s   d |  j  |  j f S(   Ns   <SubRequest %r for %r>(   R   R   (   R=   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR    s    c         C` s   |  j  j |  d  S(   N(   R   R   (   R=   R   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s    c         C` sT   | j  |  j k r7 | j t j |  j j d |   n  t t |   j	 | |  d  S(   NR   (
   Rp   t   funcargnamesR   R  R  R   R  t   superR   R   (   R=   RN   R  (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s    (   R   R   RC   R   R  R   R   (    (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s
   			s%   session package module class functionc         C` s   t  j |  t  j |   k S(   N(   Rb   R   (   t   currentscopet   newscope(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR    s    c         C` s]   y t  j |   SWnE t k
 rX t d j | | rB d j |  n d |   d t n Xd S(   s[   Look up the index of ``scope`` and raise a descriptive value error
    if not defined.
    s'   {} {}got an unexpected scope value '{}'s   from {} RV   R   N(   Rb   R   RS   R   R   Ri   (   R"   t   descrt   where(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   scope2index  s    $R   c           B` s#   e  Z d  Z d d  Z d   Z RS(   s<    could not return a requested Fixture (missing or invalid). c         C` s.   | |  _  | |  _ | j   |  _ | |  _ d  S(   N(   Rp   R   R   t   fixturestackR   (   R=   Rp   R   R   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s    		c         C` sC  g  } | j  } |  j j j g } | j t d   |  j   |  j } | d  k	 r_ | d  } n  x | D] } t	 |  \ } } y t
 j t |   \ } }	 Wn8 t t t f k
 r d }
 | |
 | | d f  qf X| d | | d f  xM t |  D]? \ } } | j   } | d |  | j   j d  r Pq q Wqf W| d  k r*|  j j } t   } |  j j j j } xK | j j   D]: \ } } t | j | |   } | r| j |  qqW|  j | k rd j |  j  } n d	 j |  j  } | d
 j d j t  |    7} | d 7} n  t! | | | | |  j  S(   Nc         S` s   |  j  S(   N(   R>   (   t   x(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   <lambda>  RV   is+   file %s, line %s: source code not availablei   s   file %s, line %ss     t   defs5    recursive dependency involving fixture '{}' detecteds   fixture '{}' not founds   
 available fixtures: {}s   , s6   
 use 'pytest --fixtures [testpath]' for help on them.("   R_   R   R   Ry   R   t   mapR  R   RB   R   R   t   getsourcelinesR   t   IOErrort
   IndexErrort	   TypeErrort	   enumeratet   rstript   lstript
   startswithR4   R   RL   RK   Rd   RY   R   t   _matchfactoriesR   Rp   R   R  R{   t   FixtureLookupErrorRepr(   R=   t   tblinest   addlineR   R   R&   R7   R   R
  R   t	   error_msgR   t   lineR   t	   availableR   RD   R   t   faclist(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt
   formatrepr  sF    			"N(   R   R   RC   RB   R   R-  (    (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s   R&  c           B` s   e  Z d    Z d   Z RS(   c         C` s1   | |  _  | |  _ | |  _ | |  _ | |  _ d  S(   N(   R'  t   errorstringR   t   firstlinenoRp   (   R=   R   R/  R'  R.  Rp   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s
    				c         C` s   x$ |  j  D] } | j | j    q
 W|  j j d  } | r | j d j t j | d j    d t	 x= | d D]. } | j d j t j
 | j    d t	 qv Wn  | j   | j d |  j |  j d f  d  S(   Ns   
s   {}       {}i    t   redi   s   %s:%d(   R'  R*  R"  R.  t   splitR   R   t   fail_markert   stript   Truet   flow_markerR   R/  (   R=   t   twt   tblineR
  R*  (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt
   toterminal  s    
(   R   R   R   R8  (    (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR&    s   	c         C` sh   t  |   \ } } d | | d f } t j j |   } t | d t | j    d | d t d  S(   Ns   %s:%si   s   :

s   
R   (   R   R5   t   _codet   SourceR   t   strt   indentRi   (   t   fixturefuncR   R  R   t   locationt   source(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   fail_fixturefunc  s    c         C` s_   t  |   } | rO |  |   } t |  } t j t |  |  } | j |  n |  |   } | S(   N(   R   t   nextR  R  t   _teardown_yield_fixtureR   (   R=  R   t   kwargst   yieldctxt   itt   resR   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   call_fixture_func  s    c         C` s3   y t  |  Wn t k
 r! n Xt |  d  d S(   s   Executes the teardown of a fixture function by advancing the iterator after the
    yield and ensure the iteration ends (if not it means there is more than one yield in the function)s0   yield_fixture function has more than one 'yield'N(   RA  t   StopIterationR@  (   R=  RE  (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyRB    s    Rg   c           B` sA   e  Z d  Z e d d  Z d   Z d   Z d   Z d   Z	 RS(   s'    A container for a factory definition. c	   	      C` s   | |  _  | p d |  _ | d  k	 |  _ | |  _ | |  _ | |  _ t | pN d d d j | j	  d | |  _
 | |  _ t | d | |  _ | |  _ | |  _ g  |  _ d  S(   NRV   R&   R  s   Fixture '{}'R  t	   is_method(   R4   RI   RB   t   has_locationR>   Rp   R"   R  R   R   Rs   RZ   R   R   t   unittestt   idst   _finalizers(	   R=   Rl   RI   Rp   R>   R"   RZ   RK  RL  (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR   /  s    							c         C` s   |  j  j |  d  S(   N(   RM  R_   (   R=   R   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR   K  s    c         C` s   g  } zn xD |  j  rO y |  j  j   } |   Wq | j t j    q Xq W| rs | d } ~ t j |   n  Wd  |  j j j	 | j
 j  } | j d |  d |  t |  d  r |  ` n  g  |  _  Xd  S(   Ni    RN   R   R!   (   RM  R   R_   t   syst   exc_infot   sixt   reraiseR4   R'   t   gethookproxyRM   R7   t   pytest_fixture_post_finalizert   hasattrR!   (   R=   R   t
   exceptionsR>   t   et   hook(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR  N  s"    
	c   
      C` s  xN |  j  D]C } | j |  } | d k r
 | j t j |  j d |  q
 q
 W| j } t |  d d   } | d  k	 r | \ } } } | | k r | d  k	 r t	 j
 |   q | Sn  |  j |  t |  d  s t  n  |  j j j | j j  }	 |	 j d |  d |  S(   NR   R!   RN   (   R   R   R   R  R  R  R   Rx   RB   RP  RQ  RT  R[   R4   R'   RR  RM   R7   t   pytest_fixture_setup(
   R=   R   Rp   RN   t   my_cache_keyR!   R   t	   cache_keyt   errRW  (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR   g  s     &	c         C` s   d |  j  |  j |  j f S(   Ns*   <FixtureDef argname=%r scope=%r baseid=%r>(   Rp   R"   RI   (   R=   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR    s    N(
   R   R   RC   Ri   RB   R   R   R  R   R  (    (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyRg   ,  s   
			c         C` s   |  j  } |  j r< | j d k	 r |  j  j | j  } q nE | j d k	 r t |  j   } | |  j  k r | j | j  } q n  | S(   s   Gets the actual callable that can be called to obtain the fixture value, dealing with unittest-specific
    instances and bound methods.
    N(   R>   RK  R9   RB   t   __get__R   (   RN   R   R=  (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   resolve_fixture_function  s    		c   
      C` s   i  } xU |  j  D]J } | j |  } | j \ } } } | j | | j | j  | | | <q Wt |  |  } | j }	 y t | | |  } Wn, t k
 r d |	 t
 j   f |  _   n X| |	 d f |  _ | S(   s    Execution of fixture setup. N(   R   R   R!   R   R"   R]  R   RG  R   RB   RN  RO  (
   RN   R   RC  Rp   t   fixdefR   t   arg_cache_keyt   excR=  RY  (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyRX    s    	c         C` s*   |  d  k r d  St |   r  |  St |   S(   N(   RB   t   callableR   (   RL  (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   _ensure_immutable_ids  s
    c         ` sO   t  j d | j p |  j    t j |     f d    } t |   | _ | S(   s   Wrap the given fixture function so we can raise an error about it being called directly,
    instead of used as an argument in a test function.
    RD   c          ` s   t    d t d  S(   NR   (   R   Ri   (   R  RC  (   t   message(    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s    (   R   R   RD   R   RP  t   wrapsR
   t   __pytest_wrapped__(   R&   t   fixture_markerR   (    (   Rc  s/   lib/python2.7/site-packages/_pytest/fixtures.pyt-   wrap_function_to_error_out_if_called_directly  s
    	t   FixtureFunctionMarkerc           B` sw   e  Z e j   Z e j d  e j j e   Z e j d e	  Z
 e j d d d  e  Z e j d d  Z d   Z RS(   t	   convertert   defaultc         C` s   t  |  r t d   n  t | d t  r< t d   n  t | |   } |  j pZ | j } | d k ry t j t	  n  |  | _
 | S(   Ns2   class fixtures not supported (maybe in the future)Rw   s<   fixture is being applied more than once to the same functionR   (   R   RS   Rx   Ri   Rg  RD   R   R   R   R   Rw   (   R=   R&   RD   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   __call__  s    	N(   R   R   R   R    R"   t
   converterst   optionalR   RZ   Ri   t   autouseRB   Rb  RL  RD   Rk  (    (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyRh    s   c         C` s   t  |   r@ | d k r@ | t k r@ t d | | d | |   S| d k	 rq t | t t f  rq t |  } n  t |  | | d | d | S(   s  Decorator to mark a fixture factory function.

    This decorator can be used, with or without parameters, to define a
    fixture function.

    The name of the fixture function can later be referenced to cause its
    invocation ahead of running tests: test
    modules or classes can use the ``pytest.mark.usefixtures(fixturename)``
    marker.

    Test functions can directly use fixture names as input
    arguments in which case the fixture instance returned from the fixture
    function will be injected.

    Fixtures can provide their values to test functions using ``return`` or ``yield``
    statements. When using ``yield`` the code block after the ``yield`` statement is executed
    as teardown code regardless of the test outcome, and must yield exactly once.

    :arg scope: the scope for which this fixture is shared, one of
                ``"function"`` (default), ``"class"``, ``"module"``,
                ``"package"`` or ``"session"``.

                ``"package"`` is considered **experimental** at this time.

    :arg params: an optional list of parameters which will cause multiple
                invocations of the fixture function and all of the tests
                using it.
                The current parameter is available in ``request.param``.

    :arg autouse: if True, the fixture func is activated for all tests that
                can see it.  If False (the default) then an explicit
                reference is needed to activate the fixture.

    :arg ids: list of string ids each corresponding to the params
                so that they are part of the test id. If no ids are provided
                they will be generated automatically from the params.

    :arg name: the name of the fixture. This defaults to the name of the
                decorated function. If a fixture is used in the same module in
                which it is defined, the function name of the fixture will be
                shadowed by the function arg that requests the fixture; one way
                to resolve this is to name the decorated function
                ``fixture_<fixturename>`` and then use
                ``@pytest.fixture(name='<fixturename>')``.
    R&   RD   RL  N(   Ra  RB   Ri   Rh  Re   R   R   (   R"   RZ   Rn  RL  RD   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   fixture  s
    .$"c         C` s%   t  d |  d | d | d | d |  S(   s    (return a) decorator to mark a yield-fixture factory function.

    .. deprecated:: 3.0
        Use :py:func:`pytest.fixture` directly instead.
    R"   RZ   Rn  RL  RD   (   Ro  (   R"   RZ   Rn  RL  RD   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   yield_fixture  s    R"   c         C` s   |  j  S(   s   Session-scoped fixture that returns the :class:`_pytest.config.Config` object.

    Example::

        def test_foo(pytestconfig):
            if pytestconfig.getoption("verbose") > 0:
                ...

    (   R   (   R   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   pytestconfig'  s    c         C` s#   |  j  d d d d g  d d d  S(   Nt   usefixturesRJ   R  Rj  t   helps5   list of default fixtures to be used with this project(   t   addini(   t   parser(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   pytest_addoption5  s
    R3   c           B` s   e  Z d  Z e Z e Z d   Z d   Z e d  Z d   Z	 d   Z
 d d  Z d   Z d   Z e e d	  Z d
   Z d   Z RS(   s  
    pytest fixtures definitions and information is stored and managed
    from this class.

    During collection fm.parsefactories() is called multiple times to parse
    fixture function definitions into FixtureDef objects and internal
    data structures.

    During collection of test functions, metafunc-mechanics instantiate
    a FuncFixtureInfo object which is cached per node/func-name.
    This FuncFixtureInfo object is later retrieved by Function nodes
    which themselves offer a fixturenames attribute.

    The FuncFixtureInfo object holds information about fixtures and FixtureDefs
    relevant for a particular function.  An initial list of fixtures is
    assembled like this:

    - ini-defined usefixtures
    - autouse-marked fixtures along the collection chain up from the function
    - usefixtures markers at module/class/function level
    - test function funcargs

    Subsequently the funcfixtureinfo.fixturenames attribute is computed
    as the closure of the fixtures needed to setup the initial fixtures,
    i. e. fixtures needed by fixture functions themselves are appended
    to the fixturenames list.

    Upon the test-setup phases all fixturenames are instantiated, retrieved
    by a lookup of their FuncFixtureInfo.
    c         C` sk   | |  _  | j |  _ i  |  _ t   |  _ i  |  _ d |  j j d  f g |  _ | j j j	 |  d  d  S(   NRV   Rr  t
   funcmanage(
   R'   R   Rd   R   t   _holderobjseent   _arg2finisht   getinit   _nodeid_and_autousenamest   pluginmanagert   register(   R=   R'   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR   a  s    			c         C` sz   d d l  m } g  } x] | j d d  D]I } | j j d t  s) | j | j | j   \ } } | j |  q) q) W| S(   s0  This function returns all the direct parametrization
        arguments of a node, so we don't mistake them for fixtures

        Check https://github.com/pytest-dev/pytest/issues/5036

        This things are done later as well when dealing with parametrization
        so this could be improved
        i    (   t   ParameterSetRD   t   parametrizet   indirect(	   t   _pytest.markR~  t   iter_markersRC  RR   Ri   t   _parse_parametrize_argsR  R   (   R=   RM   R~  t   parametrize_argnamesR   t
   p_argnamesR   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   _get_direct_parametrize_argsj  s    	c         C` s   | r. t  | d t  r. t | d | } n d } t j j d   | j d d  D  } t |  | } | j j	 } | j
 | | d |  j |  \ } }	 }
 t | | |	 |
  S(   NR   R8   c         s` s   |  ] } | j  Vq d  S(   N(   R  (   R   t   mark(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pys	   <genexpr>  s    RD   Rr  t   ignore_args(    (   Rx   Ri   R   t	   itertoolst   chaint   from_iterableR  R   R'   R4   t   getfixtureclosureR  R   (   R=   RM   R>   R8   RX   R   Rr  R   R   R   Rt   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR     s    	$c         C` s   d  } y t j j | j  j   } Wn t k
 r8 n^ X| j j d  r | j	   j
 |  j j  } | j t j k r | j | j t j  } q n  |  j | |  d  S(   Ns   conftest.py(   RB   R   R   R   t   __file__t   realpathR<   t   basenameR$  R|   R   R   R   t   sepR   t   SEPt   replacet   parsefactories(   R=   t   pluginRK   R  (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   pytest_plugin_registered  s    c         C` s   g  } xt |  j  D]i \ } } | j |  r | ri t |  } | | | d !} | ri | d k ri q qi n  | j |  q q W| S(   s-    return a tuple of fixture names to be used. i   s   :/(   R{  R$  R]   R   (   R=   RK   t   autousenamesRI   t	   basenamesR   t   nextchar(    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   _getautousenames  s    	c         ` s  | j  } |  j |    f d   } | |  t   } i    d } x | t   k r t   } xh  D]` } | | k r qq n  |   k r qq n  |  j | |  }	 |	 rq |	   | <| |	 d j  qq qq WqL W  f d   }
  j d |
  |    f S(   Nc         ` s1   x* |  D]" } |   k r   j  |  q q Wd  S(   N(   R_   (   t	   otherlistt   arg(   t   fixturenames_closure(    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   merge  s    ic         ` s;   y   |  } Wn t  k
 r+ t j d  SX| d j Sd  S(   NR&   i(   R   Rb   R   Rs   (   t   arg_nameR   (   Rt   (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   sort_by_scope  s
    R   (   RK   R  R   R]   R   R   t   sort(   R=   R   t
   parentnodeR  R   R  R   t   lastlenRp   R   R  (    (   Rt   R  s/   lib/python2.7/site-packages/_pytest/fixtures.pyR    s*    	

c   	   
   C` s.  x'| j  D]} | j j |  } | r
 | d } | j d  k	 r&t | j j d   } x | D] } d | j k r | j d } n | j	 d } t
 | t t f  s g  | j d  D] } | j   r | j   ^ q } n  | | k r` Pq` q` W| j | | j d t d | j d | j q&q
 q
 q
 Wd  S(	   NiR  R   i    t   ,R  R"   RL  (   R   Rd   RR   RZ   RB   R   t
   definitionR  RC  R  Re   R   R1  R3  R  R4  R"   RL  (	   R=   Rk   Rp   R,  RN   t   markerst   parametrize_markR   R  (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   pytest_generate_tests  s*    
7		c         C` s   t  |  | (d  S(   N(   R   (   R=   RY   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   pytest_collection_modifyitems  s    c         C` s  | t  k	 r | } n | j } | j } | |  j k r: d  S|  j j |  g  } x8t |  D]*} t | | d   } t |  } t	 | t
  s q] n  | j r | j } n  t j r | r t |  } n t | |  } t |  | | | | j | j d | d | j }	 |  j j | g   }
 |	 j r6|
 j |	  n8 t g  |
 D] } | j s@| ^ q@ } |
 j | |	  | j r] | j |  q] q] W| r|  j j | pd | f  n  d  S(   NRK  RL  RV   (   R   Ry   RK   Rx  R   t   dirR   RB   Rz   Re   Rh  RD   RP  t   PY2R   R   Rg   R"   RZ   RL  Rd   R\   RJ  R_   R]   t   insertRn  R{  (   R=   t   node_or_objRK   RK  t	   holderobjR  RD   Ry   R   t   fixture_defR,  t   fR   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR    sH    						(	c         C` s<   y |  j  | } Wn t k
 r% d SXt |  j | |   S(   s   
        Gets a list of fixtures which are applicable to the given node id.

        :param str argname: name of the fixture to search for
        :param str nodeid: full node id of the requesting test.
        :return: list[FixtureDef]
        N(   Rd   R   RB   R   R%  (   R=   Rp   RK   R   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR   ;  s
    c         c` s2   x+ | D]# } t  j | j |  r | Vq q Wd  S(   N(   R   t   ischildnodeRI   (   R=   R   RK   RN   (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR%  I  s    (    (   R   R   RC   R   R&  R   R  R4  R   R  R  R  R  R  R   Ri   R  R   R%  (    (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyR3   >  s   					0		<	(Z   t
   __future__R    R   R   R  R   R  RN  R   t   collectionsR   R   R   R   R   RP  R5   R   t   _pytest._code.codeR   R   t   _pytest.compatR	   R
   R   R   R   R   R   R   R   R   R   R   R   R   t   _pytest.deprecatedR   R   t   _pytest.outcomesR   R   t   sR4  t   objectR   R6   R*   t   dictR;   RB   RG   RQ   RU   Rv   Rz   R   R   R   R   R   Rh   R   R   R   R1  Rb   R   Ra   R  R  t   LookupErrorR   R&  R@  RG  RB  Rg   R]  RX  Rb  Rg  Rh  Ri   Ro  Rp  t   defaultfuncargprefixmarkerRq  Rv  R3   (    (    (    s/   lib/python2.7/site-packages/_pytest/fixtures.pyt   <module>   s   				:		 			(		& ,#	6			\				6				