
i\c           @` sS  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 Z e j j e	 j  j   Z d	   Z d
   Z d e f d     YZ d   Z d e f d     YZ d   Z d e f d     YZ d e f d     YZ d e f d     YZ d S(   i    (   t   absolute_import(   t   division(   t   print_functionN(   t   getfslineno(   t   NodeKeywords(   t   failt   /c         C` s:   |  d k r g  S|  j  t  } | d j  d  | d )| S(   s  Split a nodeid into constituent 'parts'.

    Node IDs are strings, and can be things like:
        ''
        'testing/code'
        'testing/code/test_excinfo.py'
        'testing/code/test_excinfo.py::TestFormattedExcinfo'

    Return values are lists e.g.
        []
        ['testing', 'code']
        ['testing', 'code', 'test_excinfo.py']
        ['testing', 'code', 'test_excinfo.py', 'TestFormattedExcinfo', '()']
    t    is   ::(   t   splitt   SEP(   t   nodeidt   parts(    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt
   _splitnode   s
    c         C` sH   t  |   } t  |  } t |  t |  k  r4 t S| t |   | k S(   s   Return True if the nodeid is a child node of the baseid.

    E.g. 'foo/bar::Baz' is a child of 'foo', 'foo/bar' and 'foo/bar::Baz', but not of 'foo/blorp'
    (   R   t   lent   False(   t   baseidR
   t
   base_partst
   node_parts(    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   ischildnode.   s
    t   Nodec           B` s   e  Z d  Z d d d d d d  Z e d    Z d   Z d   Z e d    Z	 d   Z
 d   Z d   Z d	   Z e d
  Z d d  Z d d  Z d d  Z d   Z d   Z d   Z d   Z d   Z d d  Z e Z RS(   s~    base class for Collector and Item the test collection tree.
    Collector subclasses have children, Items are terminal nodes.c         C` s   | |  _  | |  _ | p | j |  _ | p0 | j |  _ | pK t | d d   |  _ t |   |  _ g  |  _	 t
   |  _ i  |  _ | d  k	 r d | k s t  | |  _ n7 |  j j |  _ |  j  d k r |  j d |  j  7_ n  d  S(   Nt   fspaths   ::()s   ()s   ::(   t   namet   parentt   configt   sessiont   getattrt   NoneR   R   t   keywordst   own_markerst   sett   extra_keyword_matchest   _name2pseudofixturedeft   AssertionErrort   _nodeidR
   (   t   selfR   R   R   R   R   R
   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   __init__>   s    				c         C` s   |  j  j |  j  S(   s6    fspath sensitive hook proxy used to call pytest hooks(   R   t   gethookproxyR   (   R"   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   ihookd   s    c         C` s    d |  j  j t |  d d   f S(   Ns   <%s %s>R   (   t	   __class__t   __name__R   R   (   R"   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   __repr__i   s    c      	   C` s   d d l  m } t | |  s7 t d j |    n  t |   \ } } t j | d d d t	 |  d | d k	 r} | d n d d S(	   s  Issue a warning for this item.

        Warnings will be displayed after the test session, unless explicitly suppressed

        :param Warning warning: the warning instance to issue. Must be a subclass of PytestWarning.

        :raise ValueError: if ``warning`` instance is not a subclass of PytestWarning.

        Example usage:

        .. code-block:: python

            node.warn(PytestWarning("some message"))

        i    (   t   PytestWarningsB   warning must be an instance of PytestWarning or subclass, got {!r}t   categoryt   filenamet   linenoi   N(
   t   _pytest.warning_typesR)   t
   isinstancet
   ValueErrort   formatt   get_fslocation_from_itemt   warningst   warn_explicitR   t   str(   R"   t   warningR)   t   pathR,   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   warnl   s    c         C` s   |  j  S(   s=    a ::-separated string denoting its collection tree address. (   R!   (   R"   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR
      s    c         C` s   t  |  j  S(   N(   t   hashR
   (   R"   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   __hash__   s    c         C` s   d  S(   N(    (   R"   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   setup   s    c         C` s   d  S(   N(    (   R"   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   teardown   s    c         C` sC   g  } |  } x& | d k	 r4 | j |  | j } q W| j   | S(   se    return list of all parent collectors up to self,
            starting from root of collection tree. N(   R   t   appendR   t   reverse(   R"   t   chaint   item(    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt	   listchain   s    
c         C` s   d d l  m } m } t | t j  r: t | |  } n t | |  sX t d   n  | |  j | j	 <| r |  j
 j | j  n |  j
 j d | j  d S(   s   dynamically add a marker object to the node.

        :type marker: ``str`` or ``pytest.mark.*``  object
        :param marker:
            ``append=True`` whether to append the marker,
            if ``False`` insert at position ``0``.
        i    (   t   MarkDecoratort   MARK_GENs'   is not a string or pytest.mark.* MarkerN(   t   _pytest.markRA   RB   R.   t   sixt   string_typesR   R/   R   R   R   R<   t   markt   insert(   R"   t   markerR<   RA   RB   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt
   add_marker   s    c         C` s   d   |  j  d |  D S(   s   
        :param name: if given, filter the results by the name attribute

        iterate over all markers of the node
        c         s` s   |  ] } | d  Vq d S(   i   N(    (   t   .0t   x(    (    s,   lib/python2.7/site-packages/_pytest/nodes.pys	   <genexpr>   s    R   (   t   iter_markers_with_node(   R"   R   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   iter_markers   s    c         c` sg   x` t  |  j    D]L } xC | j D]8 } | d k sM t | d d  | k r# | | f Vq# q# Wq Wd S(   s   
        :param name: if given, filter the results by the name attribute

        iterate over all markers of the node
        returns sequence of tuples (node, mark)
        R   N(   t   reversedR@   R   R   R   (   R"   R   t   nodeRF   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyRL      s    $c         C` s   t  |  j d |  |  S(   s   return the first marker matching the name, from closest (for example function) to farther level (for example
        module level).

        :param default: fallback return value of no marker was found
        :param name: name to filter by
        R   (   t   nextRM   (   R"   R   t   default(    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   get_closest_marker   s    c         C` s4   t    } x$ |  j   D] } | j | j  q W| S(   s<    Return a set of all extra keywords in self and any parents.(   R   R@   t   updateR   (   R"   t   extra_keywordsR?   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   listextrakeywords   s    	c         C` s    g  |  j    D] } | j ^ q S(   N(   R@   R   (   R"   RK   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt	   listnames   s    c         C` s   |  j  j j | |   d S(   s    register a function to be called when this node is finalized.

        This method can only be called when this node is active
        in a setup chain, for example during self.setup().
        N(   R   t   _setupstatet   addfinalizer(   R"   t   fin(    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyRX      s    c         C` s0   |  } x# | r+ t  | |  r+ | j } q	 W| S(   s]    get the next parent node (including ourself)
        which is an instance of the given class(   R.   R   (   R"   t   clst   current(    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt	   getparent   s    c         C` s   d  S(   N(    (   R"   t   excinfo(    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   _prunetraceback   s    c         C` s  | j  t j  r1 | j j s1 t j | j  Sn  |  j j } | j  | j	  r\ | j j
   St } |  j j d t  r d } ne t j j | j d g  } |  j |  t | j  d k r | | _ n  t } | d k r d } n  | d  k r|  j j d d  d k rd } qd } n  |  j j d d  d	 k rBt } n t } y t j   t } Wn t k
 rut } n X| j d
 t d | d |  j j d t  d | d | d |  S(   Nt	   fulltracet   longii    t   autot   tbstylet   shortt   verbosei   t   funcargst   abspatht
   showlocalst   stylet   tbfiltert   truncate_locals(   t   errisinstanceR   t	   Exceptiont   valuet   pytraceRD   t	   text_typeR   t   _fixturemanagert   FixtureLookupErrort
   formatreprt   TrueR   t	   getoptionR   t   _pytestt   _codet	   Tracebackt	   tracebackR^   R   R   t   ost   getcwdt   OSErrort   getrepr(   R"   R]   Rh   t   fmRi   t   tbRj   Rf   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   _repr_failure_py   sF    					


	N(   R'   t
   __module__t   __doc__R   R#   t   propertyR%   R(   R7   R
   R9   R:   R;   R@   Rs   RI   RM   RL   RR   RU   RV   RX   R\   R^   R   t   repr_failure(    (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR   :   s*   %		!										-c         C` sd   t  |  d d  } | d k	 r& | d  St  |  d d  } | d k	 rN t |  St  |  d d  d f S(   s  Tries to extract the actual location from an item, depending on available attributes:

    * "fslocation": a pair (path, lineno)
    * "obj": a Python object that the item wraps.
    * "fspath": just a path

    :rtype: a tuple of (str|LocalPath, int) with filename and line number.
    t   locationi   t   objR   s   unknown locationiN(   R   R   R   (   R?   t   resultR   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR1   $  s    	
t	   Collectorc           B` s?   e  Z d  Z d e f d     YZ d   Z d   Z d   Z RS(   sf    Collector instances create children through collect()
        and thus iteratively build a tree.
    t   CollectErrorc           B` s   e  Z d  Z RS(   s8    an error during collection, contains a custom message. (   R'   R   R   (    (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR   ;  s   c         C` s   t  d   d S(   sa    returns a list of children (items and collectors)
            for this collection node.
        t   abstractN(   t   NotImplementedError(   R"   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   collect>  s    c         C` sf   | j  |  j  r, | j } t | j d  S|  j j d  } | d k rS d } n  |  j | d | S(   s!    represent a collection failure. i    Rb   Ra   Rc   Rh   (   Rk   R   Rm   R4   t   argsR   Rt   R   (   R"   R]   t   excRb   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR   D  s    		c         C` sd   t  |  d  r` | j } | j d |  j  } | | k rN | j d t  } n  | j   | _ n  d  S(   NR   R6   t   excludepath(   t   hasattrRx   t   cutR   t   tracebackcutdirt   filter(   R"   R]   Rx   t
   ntraceback(    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR^   R  s    	(   R'   R   R   Rl   R   R   R   R^   (    (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR   6  s
   		c         C` s:   x3 |  j  D]( } | j |  | k r
 | j |  Sq
 Wd  S(   N(   t   _initialpathst   commont   relto(   R   R   t   initial_path(    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   _check_initialpaths_for_relpath[  s    t   FSCollectorc           B` s   e  Z d d d d d   Z RS(   c      	   C` s  t  j j |  } | j } | d  k	 r` | j | j  } | rH | } n  | j t j	 t
  } n  | |  _ | pu | j } | d  k r |  j j | j j  } | s t | |  } n  | r t j	 t
 k r | j t j	 t
  } q n  t t |   j | | | | d | d | d  S(   NR
   R   (   t   pyR6   t   localt   basenameR   R   R   t   replaceRy   t   sepR	   R   R   t   rootdirR   t   superR   R#   (   R"   R   R   R   R   R
   R   t   rel(    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR#   b  s"    			N(   R'   R   R   R#   (    (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR   a  s   t   Filec           B` s   e  Z d  Z RS(   s.    base class for collecting tests from a file. (   R'   R   R   (    (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR   {  s   t   Itemc           B` sJ   e  Z d  Z d Z d d d d d  Z d   Z d   Z e d    Z	 RS(   sv    a basic test invocation item. Note that for a single function
    there might be multiple test invocation items.
    c         C` s;   t  t |   j | | | | d | g  |  _ g  |  _ d  S(   NR
   (   R   R   R#   t   _report_sectionst   user_properties(   R"   R   R   R   R   R
   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR#     s    %	c         C` s&   | r" |  j  j | | | f  n  d S(   s$  
        Adds a new report section, similar to what's done internally to add stdout and
        stderr captured output::

            item.add_report_section("call", "stdout", "report section contents")

        :param str when:
            One of the possible capture states, ``"setup"``, ``"call"``, ``"teardown"``.
        :param str key:
            Name of the section, can be customized at will. Pytest uses ``"stdout"`` and
            ``"stderr"`` internally.

        :param str content:
            The full contents as a string.
        N(   R   R<   (   R"   t   whent   keyt   content(    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   add_report_section  s    c         C` s   |  j  d  d f S(   NR   (   R   R   (   R"   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt
   reportinfo  s    c         C` sl   y |  j  SWnZ t k
 rg |  j   } |  j j | d  } | | d t | d  f } | |  _  | SXd  S(   Ni    i   i   (   t	   _locationt   AttributeErrorR   R   t   _node_location_to_relpathR4   (   R"   R   R   (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR     s    	N(
   R'   R   R   R   t   nextitemR#   R   R   R   R   (    (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyR     s   		(    t
   __future__R    R   R   Ry   R2   R   RD   t   _pytest._codeRu   t   _pytest.compatR   t   _pytest.mark.structuresR   t   _pytest.outcomesR   R	   R6   R   t   __file__t   dirpathR   R   R   t   objectR   R1   R   R   R   R   R   (    (    (    s,   lib/python2.7/site-packages/_pytest/nodes.pyt   <module>   s*   			%	