ó
çiõ\c           @   sÌ  d  d l  Z  d  d l Z d  d l m Z d  d l m 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 Z d d „ Z d „  Z d „  Z d e d d ƒ f d „  ƒ  YZ e j d e ƒ d e f d „  ƒ  Yƒ Z e j d e f d „  ƒ  Yƒ Z d „  Z d „  Z d „  Z  d e f d „  ƒ  YZ! e! ƒ  Z" d e f d „  ƒ  YZ# e j d e$ d  e$ ƒ d! e f d" „  ƒ  Yƒ Z% d S(#   iÿÿÿÿN(   t
   namedtuple(   t
   attrgetteri   (   t   ascii_escaped(   t   getfslineno(   t   MappingMixin(   t   NOTSET(   t   PYTEST_PARAM_UNKNOWN_KWARGS(   t   fail(   t   PytestUnknownMarkWarningt   empty_parameter_set_markc            sD   t  |  ƒ ‰  ‡  ‡ f d †  } t ˆ d  k r3 ˆ  n | d d |  ƒS(   Nc            s   t  j ˆ d d ƒˆ  |  ƒ S(   Nt
   stackleveli   (   t   warningst   warn(   t   self(   t   gettert   warning(    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   warned   s    t   docs
   alias for (   R   t   propertyt   None(   t   nameR   R   (    (   R   R   s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   alias   s    c         C   s%   t  |  d ƒ o$ t |  d d ƒ d k S(   Nt   __call__t   __name__s   <lambda>(   t   hasattrt   getattr(   t   func(    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt
   istestfunc   s    c         C   sã   d d l  m } |  j t ƒ } | d k r7 t j } nt | d k rX t j d t ƒ } nS | d k rŸ | j	 } t
 | ƒ \ } } | j d | | d	 f ƒ ‚ n t | ƒ ‚ t
 | ƒ \ }	 } d
 | | j	 |	 | f }
 | d |
 ƒ S(   Ni   (   t	   Collectort    t   skipt   xfailt   runt   fail_at_collects&   Empty parameter set in '%s' at line %di   s0   got empty parameter set %r, function %s at %s:%dt   reason(   R   NR   (   t   nodesR   t   getinit   EMPTY_PARAMETERSET_OPTIONR   t   MARK_GENR   R   t   FalseR   R   t   CollectErrort   LookupError(   t   configt   argnamesR   R   t   requested_markt   markt   f_namet   _t   linenot   fsR"   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   get_empty_parameterset_mark&   s&    	
t   ParameterSets   values, marks, idc           B   sV   e  Z e d  „  ƒ Z e e d „ ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 RS(   c         O   sé   | j  d d ƒ } t | t ƒ r- | f } n t | t t t f ƒ sK t ‚ | j  d d  ƒ } | d  k	 r« t | t j	 ƒ sœ t
 d j t | ƒ | ƒ ƒ ‚ n  t | ƒ } n  | rÙ t j t j d t | ƒ ƒ d d ƒn  |  | | | ƒ S(   Nt   markst   ids(   Expected id to be a string, got {}: {!r}t   argsR
   i   (    (   t   popt
   isinstancet   MarkDecoratort   tuplet   listt   sett   AssertionErrorR   t   sixt   string_typest	   TypeErrort   formatt   typeR   R   R   R   t   sorted(   t   clst   valuest   kwargsR4   t   id_(    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   paramA   s    "c         C   s@   t  | |  ƒ r | S| r& |  j | ƒ S|  | d g  d d ƒSd S(   sE  
        :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 force_tuple:
            enforce tuple wrapping so single argument tuple values
            don't get decomposed and break tests
        R4   R5   N(   R8   RH   R   (   RD   t   parametersett   force_tuple(    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   extract_fromW   s
    c         K   sn   t  |  t t f ƒ s^ g  |  j d ƒ D] } | j ƒ  r% | j ƒ  ^ q% }  t |  ƒ d k } n t } |  | f S(   s¡   It receives an ignored _ (kwargs) argument so this function can
        take also calls from parametrize ignoring scope, indirect, and other
        arguments...t   ,i   (   R8   R:   R;   t   splitt   stript   lenR'   (   R+   t	   argvaluesR/   t   xRJ   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   _parse_parametrize_argsj   s
    4c         C   s&   g  |  D] } t  j | d | ƒ^ q S(   NRJ   (   R3   RK   (   RP   RJ   RQ   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   _parse_parametrize_parametersv   s    c         C   s  |  j  | | ƒ \ } } |  j | | ƒ } ~ | r´ xÂ | D]s } t | j ƒ t | ƒ k r: d }	 t |	 j d | j d | j d | d t | ƒ d t | j ƒ ƒ d t ƒq: q: WnD t | | | ƒ }
 | j	 t
 d t f t | ƒ d |
 g d	 d  ƒ ƒ | | f S(
   Nsˆ   {nodeid}: in "parametrize" the number of names ({names_len}):
  {names}
must be equal to the number of values ({values_len}):
  {values}t   nodeidRE   t   namest	   names_lent
   values_lent   pytraceR4   R5   (   RR   RS   RO   RE   R   RA   RT   R'   R2   t   appendR3   R   R   (   RD   R+   RP   R   R*   t   function_definitionRJ   t
   parametersRH   t   msgR-   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   _for_parametrize|   s&    			,(
   R   t
   __module__t   classmethodRH   R'   RK   t   staticmethodRR   RS   R]   (    (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyR3   @   s   t   frozent   Markc           B   s;   e  Z e j d  e ƒ Z e j ƒ  Z e j ƒ  Z d „  Z RS(   RB   c         C   sD   |  j  | j  k s t ‚ t |  j  |  j | j t |  j | j  ƒ S(   s¤   
        :param other: the mark to combine with
        :type other: Mark
        :rtype: Mark

        combines by appending args and merging the mappings
        (   R   R=   Rb   R6   t   dictRF   (   R   t   other(    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   combined_with©   s    (	   R   R^   t   attrt   ibt   strR   R6   RF   Re   (    (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyRb       s   R9   c           B   sƒ   e  Z d  Z e j d e j j e ƒ ƒ Z e	 d ƒ Z
 e	 d ƒ Z e	 d ƒ Z e d „  ƒ Z 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.

    t	   validators	   mark.names	   mark.argss   mark.kwargsc         C   s   |  j  S(   N(   R   (   R   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   marknameà   s    c         C   s#   t  | t ƒ r |  j | j k St S(   N(   R8   R9   R-   R'   (   R   Rd   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   __eq__ä   s    c         C   s   d |  j  f S(   Ns   <MarkDecorator %r>(   R-   (   R   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   __repr__ç   s    c         O   s.   t  |  j | | ƒ } |  j |  j j | ƒ ƒ S(   s¯    return a MarkDecorator with extra arguments added

        unlike call this can be used even if the sole argument is a callable/class

        :return: MarkDecorator
        (   Rb   R   t	   __class__R-   Re   (   R   R6   RF   R-   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt	   with_argsê   s    c         O   sq   | ra | ra | d } t  j | ƒ } t | ƒ d k ra t | ƒ sJ | ra t | |  j ƒ | Sn  |  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   inspectt   isclassRO   R   t
   store_markR-   Rn   (   R   R6   RF   R   t   is_class(    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyR   õ   s    
$(   R   R^   t   __doc__Rf   Rg   t
   validatorst   instance_ofRb   R-   R   R   R6   RF   R   Rj   Rk   Rl   Rn   R   (    (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyR9   ·   s   !			c         C   s7   t  |  d g  ƒ } t | t ƒ s- | g } n  t | ƒ S(   s@   
    obtain the unpacked marks that are stored on an object
    t
   pytestmark(   R   R8   R;   t   normalize_mark_list(   t   objt	   mark_list(    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   get_unpacked_marks  s    c         C   sƒ   g  |  D] } t  | d | ƒ ^ q } x5 | D]- } t | t ƒ s, t d j | ƒ ƒ ‚ q, q, Wg  | D] } t | t ƒ rd | ^ qd S(   sŒ   
    normalizes marker decorating helpers to mark objects

    :type mark_list: List[Union[Mark, Markdecorator]]
    :rtype: List[Mark]
    R-   s   got {!r} instead of Mark(   R   R8   Rb   R@   RA   (   Ry   R-   t	   extractedRQ   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyRw     s
    %c         C   s5   t  | t ƒ s t | ƒ ‚ t |  ƒ | g |  _ d S(   sg   store a Mark on an object
    this is used to implement the Mark declarations/decorators correctly
    N(   R8   Rb   R=   Rz   Rv   (   Rx   R-   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyRq     s    t   MarkGeneratorc           B   s&   e  Z d  Z d Z e ƒ  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   sý   | d d k r t  d ƒ ‚ n  |  j d  k	 rç | |  j k r“ xS |  j j d ƒ D]< } | j d ƒ d j d ƒ d j ƒ  } |  j j | ƒ qP Wn  | |  j k rç |  j j j	 rÍ t
 d j | ƒ d t ƒqä t j d	 | t ƒ qç n  t t | d
 i  ƒ ƒ S(   Ni    R/   s*   Marker name must NOT start with underscoret   markerst   :t   (s0   {!r} not found in `markers` configuration optionRX   sœ   Unknown pytest.mark.%s - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html(    (   t   AttributeErrort   _configR   t   _markersR$   RM   RN   t   addt   optiont   strict_markersR   RA   R'   R   R   R   R9   Rb   (   R   R   t   linet   marker(    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   __getattr__4  s"    &
N(   R   R^   Rs   R   R   R<   R‚   Rˆ   (    (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyR|   %  s   
	t   NodeKeywordsc           B   sP   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   c         C   s,   | |  _  | j |  _ i t | j 6|  _ d  S(   N(   t   nodet   parentt   TrueR   R‚   (   R   RŠ   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   __init__[  s    	c         C   sG   y |  j  | SWn1 t k
 rB |  j d  k r4 ‚  n  |  j j | SXd  S(   N(   R‚   t   KeyErrorR‹   R   t   keywords(   R   t   key(    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   __getitem__`  s    c         C   s   | |  j  | <d  S(   N(   R‚   (   R   R   t   value(    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   __setitem__h  s    c         C   s   t  d ƒ ‚ d  S(   Ns"   cannot delete key in keywords dict(   t
   ValueError(   R   R   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   __delitem__k  s    c         C   s   |  j  ƒ  } t | ƒ S(   N(   t   _seent   iter(   R   t   seen(    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   __iter__n  s    c         C   s8   t  |  j ƒ } |  j d  k	 r4 | j |  j j ƒ n  | S(   N(   R<   R‚   R‹   R   t   updateR   (   R   R˜   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyR–   r  s    c         C   s   t  |  j ƒ  ƒ S(   N(   RO   R–   (   R   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   __len__x  s    c         C   s   d |  j  f S(   Ns   <NodeKeywords for node %s>(   RŠ   (   R   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyRl   {  s    (
   R   R^   R   R‘   R“   R•   R™   R–   R›   Rl   (    (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyR‰   Z  s   							t   cmpt   hasht   NodeMarkersc           B   sD   e  Z d  Z e j d e j e ƒ ƒ Z d „  Z d „  Z	 d „  Z
 RS(   sj   
    internal structure for storing marks belonging to a node

    ..warning::

        unstable api

    t   defaultc         C   s   |  j  j | ƒ d S(   s   update the own markers
        N(   t   own_markerst   extend(   R   t   add_markers(    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyRš   Œ  s    c         c   s/   x( |  j  D] } | j | k r
 | Vq
 q
 Wd S(   sX   
        find markers in own nodes or parent nodes
        needs a better place
        N(   R    R   (   R   R   R-   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   find‘  s    c         C   s   t  |  j ƒ S(   N(   R—   R    (   R   (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyR™   š  s    (   R   R^   Rs   Rf   Rg   t   FactoryR;   R    Rš   R£   R™   (    (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyRž     s
   				(&   Ro   R   t   collectionsR    t   operatorR   Rf   R>   t   compatR   R   R   R   t   _pytest.deprecatedR   t   _pytest.outcomesR   t   _pytest.warning_typesR   R%   R   R   R   R2   R3   t   sRŒ   t   objectRb   R9   Rz   Rw   Rq   R|   R&   R‰   R'   Rž   (    (    (    s6   lib/python2.7/site-packages/_pytest/mark/structures.pyt   <module>   s:   
		`	I	
		
2	%