ó
…¾^Yc           @` s„  d  Z  d d l m Z m Z m Z d d l Z d d l m Z d d l m	 Z	 d d l
 m Z d „  Z d	 e d	 d
 ƒ f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d „  Z d „  Z e e _ d „  Z d d$ d „  ƒ  YZ d d% d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z d d& d „  ƒ  YZ d „  Z d d' d „  ƒ  YZ d e d d  ƒ f d! „  ƒ  YZ d" e  f d# „  ƒ  YZ! e ƒ  Z" d S((   s?    generic mechanism for marking and selecting python functions. i    (   t   absolute_importt   divisiont   print_functionN(   t
   namedtuple(   t
   attrgetteri   (   t   imapc         C` s   t  t |  ƒ d d |  ƒS(   Nt   docs
   alias for (   t   propertyR   (   t   name(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   alias
   s    t   ParameterSets   values, marks, idc           B` s8   e  Z e d  „  ƒ Z e e d „ ƒ Z e d „  ƒ Z RS(   c         O` ss   | j  d d ƒ } t | t ƒ r- | f } n t | t t t f ƒ sK t ‚ d  d „ } | |   } |  | | | ƒ S(   Nt   marksc         S` s   |  S(   N(    (   t   id(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   param_extract_id   s    (    (   t   popt
   isinstancet   MarkDecoratort   tuplet   listt   sett   AssertionErrort   None(   t   clst   valuest   kwR   R   R   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   param   s    c         C` sÏ   t  | |  ƒ r | St  | t ƒ r6 | r6 |  j | ƒ Sg  } | } xL t  | t ƒ r | j t t | j | j d  | j ƒ ƒ ƒ | j d } qE Wt  | t ƒ s§ t	 ‚ | r¹ | f } n  |  | d | d d ƒS(   sM  
        :param parameterset:
            a legacy style parameterset that may or may not be a tuple,
            and may or may not be wrapped into a mess of mark objects

        :param legacy_force_tuple:
            enforce tuple wrapping so single argument tuple values
            don't get decomposed and break tests

        iÿÿÿÿR   R   N(   R   R   R   t   appendt   Markt   marknamet   argst   kwargsR
   R   R   (   R   t   parametersett   legacy_force_tuplet   newmarkst   argval(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   extract_from   s     c         C` s   t  d „  |  j Dƒ ƒ S(   Nc         s` s   |  ] } | j  | f Vq d  S(   N(   R   (   t   .0t   mark(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pys	   <genexpr>=   s    (   t   dictR   (   t   self(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   deprecated_arg_dict;   s    (   t   __name__t
   __module__t   classmethodR   t   FalseR#   R   R(   (    (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyR
      s   t   MarkerErrorc           B` s   e  Z d  Z RS(   s*   Error in use of a pytest marker/attribute.(   R)   R*   t   __doc__(    (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyR-   @   s   c          O` s   t  j |  | Ž  S(   N(   R
   R   (   R   R   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyR   E   s    c         C` s•   |  j  d ƒ } | j d d d d d d d d	 d
 d d ƒ| j d d d d d d d d	 d d d ƒ| j d d d d d ƒ|  j d d d ƒ d  S(   Nt   generals   -kt   actiont   storet   destt   keywordt   defaultt    t   metavart
   EXPRESSIONt   helpsù  only run tests which match the given substring expression. An expression is a python evaluatable expression where all names are substring-matched against test names and their parent classes. Example: -k 'test_method or test_other' matches all test functions and classes whose name contains 'test_method' or 'test_other'. Additionally keywords are matched to classes and functions containing extra names in their 'extra_keyword_matches' set, as well as functions which have names assigned directly to them.s   -mt   markexprt   MARKEXPRsR   only run tests matching given mark expression.  example: -m 'mark1 and not mark2'.s	   --markerst
   store_trues4   show markers (builtin, plugin and per-project ones).t   markerss   markers for test functionst   linelist(   t   getgroupt
   _addoptiont	   addoptiont   addini(   t   parsert   group(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   pytest_addoptionI   s    c         C` s¦   d d  l  } |  j j r¢ |  j ƒ  | j j |  ƒ } x] |  j d ƒ D]L } | j d d ƒ \ } } | j d | d t	 ƒ| j
 | ƒ | j
 ƒ  qD W|  j ƒ  d Sd  S(   Ni    R<   t   :i   s   @pytest.mark.%s:t   bold(   t   _pytest.configt   optionR<   t   _do_configuret   configt   create_terminal_writert   getinit   splitt   writet   Truet   linet   _ensure_unconfigure(   RJ   t   _pytestt   twRP   R   t   rest(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   pytest_cmdline_mainh   s    

c         C` s*  | j  j j ƒ  } | j  j } | r0 | r0 d  S| j d ƒ rP d | d } n  t } | d d k ry t } | d  } n  g  } g  } x{ |  D]s } | r¸ t | | ƒ r¸ | j | ƒ qŒ | rÇ d  } n  | rò t
 | | ƒ sò | j | ƒ qŒ qò n  | j | ƒ qŒ W| r&| j j d | ƒ | |  (n  d  S(   Nt   -s   not i   iÿÿÿÿRE   t   items(   RH   R3   t   lstripR9   t
   startswithR,   RO   t   matchkeywordR   R   t	   matchmarkt   hookt   pytest_deselected(   RW   RJ   t   keywordexprt	   matchexprt   selectuntilt	   remainingt
   deselectedt   colitem(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   pytest_collection_modifyitemsy   s2    		t   MarkMappingc           B` s    e  Z d  Z d „  Z d „  Z RS(   sf   Provides a local mapping for markers where item access
    resolves to True if the marker is present. c         C` sa   t  ƒ  } xH | j ƒ  D]: \ } } t | t ƒ s@ t | t ƒ r | j | ƒ q q W| |  _ d  S(   N(   R   RW   R   t   MarkInfoR   t   addt   _mymarks(   R'   t   keywordst   mymarkst   keyt   value(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   __init__ž   s
    	c         C` s   | |  j  k S(   N(   Rh   (   R'   R   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   __getitem__¥   s    (   R)   R*   R.   Rm   Rn   (    (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyRe   ›   s   	t   KeywordMappingc           B` s    e  Z d  Z d „  Z d „  Z RS(   sw   Provides a local mapping for keywords.
    Given a list of names, map any substring of one of these names to True.
    c         C` s   | |  _  d  S(   N(   t   _names(   R'   t   names(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyRm   ­   s    c         C` s(   x! |  j  D] } | | k r
 t Sq
 Wt S(   N(   Rp   RO   R,   (   R'   t   subnameR   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyRn   °   s    (   R)   R*   R.   Rm   Rn   (    (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyRo   ©   s   	c         C` s   t  | i  t |  j ƒ ƒ S(   sB   Tries to match on any marker names, attached to the given colitem.(   t   evalRe   Ri   (   Rc   R9   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyR[   ·   s    c         C` s  t  ƒ  } d d l } x9 |  j ƒ  D]+ } t | | j ƒ s" | j | j ƒ q" q" Wx! |  j ƒ  D] } | j | ƒ q^ Wt |  d ƒ r« x$ |  j	 j
 D] } | j | ƒ q‘ Wn  t | ƒ } d | k rË | | S| j d ƒ r÷ d | d k r÷ | | d St | i  | ƒ S(   s|  Tries to match given keyword expression to given collector item.

    Will match on the name of colitem, including the names of its parents.
    Only matches names of items which are either a :class:`Class` or a
    :class:`Function`.
    Additionally, matches on names in the 'extra_keyword_matches' set of
    any item, as well as names directly assigned to test functions.
    i    Nt   functiont    s   not i   (   R   t   pytestt	   listchainR   t   InstanceRg   R   t   listextrakeywordst   hasattrRt   t   __dict__Ro   RY   Rs   (   Rc   R^   t   mapped_namesRv   t   itemR   t   mapping(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyRZ   ¼   s     		c         C` s(   t  j |  _ |  j j r$ |  t  _ n  d  S(   N(   t   MARK_GENt   _configt   _old_mark_configRH   t   strict(   RJ   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   pytest_configureß   s    c         C` s   t  |  d d  ƒ t _ d  S(   NR   (   t   getattrR   R   R€   (   RJ   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   pytest_unconfigureå   s    t   MarkGeneratorc           B` s&   e  Z d  Z d Z d „  Z d „  Z RS(   s-   Factory for :class:`MarkDecorator` objects - exposed as
    a ``pytest.mark`` singleton instance.  Example::

         import pytest
         @pytest.mark.slowtest
         def test_function():
            pass

    will set a 'slowtest' :class:`MarkInfo` object
    on the ``test_function`` object. c         C` sT   | d d k r t  d ƒ ‚ n  |  j d  k	 r> |  j | ƒ n  t t | d i  ƒ ƒ S(   Ni    t   _s*   Marker name must NOT start with underscore(    (   t   AttributeErrorR€   R   t   _checkR   R   (   R'   R   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   __getattr__÷   s
    c         C` sº   y | |  j  k r d  SWn t k
 r* n Xt ƒ  |  _  } xS |  j j d ƒ D]? } | j d d ƒ } | d j d d ƒ d } | j | ƒ qN W| |  j  k r¶ t d | f ƒ ‚ n  d  S(   NR<   RE   i   i    t   (s   %r not a registered marker(   t   _markersRˆ   R   R€   RL   RM   Rg   (   R'   R   t   lRP   t	   beginningt   x(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyR‰   þ   s    N(   R)   R*   R.   R   R€   RŠ   R‰   (    (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyR†   é   s   
	c         C` s%   t  |  d ƒ o$ t |  d d ƒ d k S(   Nt   __call__R)   s   <lambda>(   Rz   R„   (   t   func(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt
   istestfunc  s    R   c           B` se   e  Z d  Z d „  Z e d ƒ Z e d ƒ Z e d ƒ Z e d „  ƒ Z	 d „  Z
 d „  Z d „  Z RS(	   sò   A decorator for test functions and test classes.  When applied
    it will create :class:`MarkInfo` objects which may be
    :ref:`retrieved by hooks as item keywords <excontrolskip>`.
    MarkDecorator instances are often created like this::

        mark1 = pytest.mark.NAME              # simple MarkDecorator
        mark2 = pytest.mark.NAME(name1=value) # parametrized MarkDecorator

    and can then be applied as decorators to test functions::

        @mark2
        def test_function():
            pass

    When a MarkDecorator instance is called it does the following:
      1. If called with a single class as its only positional argument and no
         additional keyword arguments, it attaches itself to the class so it
         gets applied automatically to all test cases found in that class.
      2. If called with a single function as its only positional argument and
         no additional keyword arguments, it attaches a MarkInfo object to the
         function, containing all the arguments already stored internally in
         the MarkDecorator.
      3. When called in any other case, it performs a 'fake construction' call,
         i.e. it returns a new MarkDecorator instance with the original
         MarkDecorator's content updated with the arguments passed to this
         call.

    Note: The rules above prevent MarkDecorator objects from storing only a
    single function or class reference as their positional argument with no
    additional keyword or positional arguments.

    c         C` s.   t  | t ƒ s! t t | ƒ ƒ ‚ | |  _ d  S(   N(   R   R   R   t   reprR%   (   R'   R%   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyRm   2  s    !s	   mark.names	   mark.argss   mark.kwargsc         C` s   |  j  S(   N(   R   (   R'   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyR   :  s    c         C` s   |  j  | j  k S(   N(   R%   (   R'   t   other(    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   __eq__>  s    c         C` s   d |  j  f S(   Ns   <MarkDecorator %r>(   R%   (   R'   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   __repr__A  s    c         O` s6  | r| r| d } t  j | ƒ } t | ƒ d k rt | ƒ sJ | r| r« t | d ƒ rœ | j } t | t ƒ sƒ | g } n  | |  g } | | _ q|  g | _ nV t | |  j	 d ƒ } | d k rñ t |  j ƒ } t | |  j	 | ƒ n | j |  j ƒ | Sn  t |  j	 | | ƒ } |  j |  j j | ƒ ƒ S(   sŠ    if passed a single callable argument: decorate it with mark info.
            otherwise add *args/**kwargs in-place to mark information. i    i   t
   pytestmarkN(   t   inspectt   isclasst   lenR’   Rz   R—   R   R   R„   R   R   Rf   R%   t   setattrt   add_markR   t	   __class__t   combined_with(   R'   R   R   R‘   t   is_classt	   mark_listt   holderR%   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyR   D  s(    
$	(   R)   R*   R.   Rm   R	   R   R   R   R   R   R•   R–   R   (    (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyR     s    			R   s   name, args, kwargsc           B` s   e  Z d  „  Z RS(   c         C` sD   |  j  | j  k s t ‚ t |  j  |  j | j t |  j | j  ƒ S(   N(   R   R   R   R   R&   R   (   R'   R”   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyRž   h  s    (   R)   R*   Rž   (    (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyR   f  s   Rf   c           B` sV   e  Z d  Z d „  Z e d ƒ Z e d ƒ Z e d ƒ Z d „  Z d „  Z	 d „  Z
 RS(   s=    Marking object created by :class:`MarkDecorator` instances. c         C` s:   t  | t ƒ s! t t | ƒ ƒ ‚ | |  _ | g |  _ d  S(   N(   R   R   R   R“   t   combinedt   _marks(   R'   R%   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyRm   q  s    !	s   combined.names   combined.argss   combined.kwargsc         C` s   d j  |  j ƒ S(   Ns   <MarkInfo {0!r}>(   t   formatR¢   (   R'   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyR–   z  s    c         C` s)   |  j  j | ƒ |  j j | ƒ |  _ d S(   s0    add a MarkInfo with the given args and kwargs. N(   R£   R   R¢   Rž   (   R'   R%   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyRœ   }  s    c         C` s   t  t |  j ƒ S(   s9    yield MarkInfo objects each relating to a marking-call. (   R   Rf   R£   (   R'   (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   __iter__‚  s    (   R)   R*   R.   Rm   R	   R   R   R   R–   Rœ   R¥   (    (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyRf   o  s   			(    (    (    (    (#   R.   t
   __future__R    R   R   R˜   t   collectionsR   t   operatorR   t   compatR   R	   R
   t	   ExceptionR-   R   RD   RU   RO   t   tryfirstRd   Re   Ro   R[   RZ   Rƒ   R…   R†   R’   R   R   t   objectRf   R   (    (    (    s,   /tmp/pip-build-hU8Cw8/pytest/_pytest/mark.pyt   <module>   s2   	2					"		#		$	U	