o
    #ifRh                     @   s$  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 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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/m0Z0 d d"l1m2Z2 d d#l1m3Z3 d d$l4m5Z5 d d%l6m7Z7 erd d&lm8Z8 d d'lm9Z9 d d(l:m;Z; d)Z<eej=j>Z?ed*Z@d+ed, d-ee d.ee# d/efd0d1ZAed2d,d3ZBG d4d5 d5e jCZDG d6d, d,e jEeDd7ZFd8d,d/eeeGef eeH f fd9d:ZIG d;d< d<eFe jEZJd=d>d-ed/eeG fd?d@ZKG dAdB dBeJe jEZLG dCdD dDeLe jEZMG dEdF dFeLe jEZNG dGdH dHeFe jEZOdS )I    N)cached_property)	signature)Path)Any)Callable)cast)Iterable)Iterator)List)MutableMapping)NoReturn)Optional)overload)Set)Tuple)Type)TYPE_CHECKING)TypeVar)Union)getfslineno)ExceptionInfo)TerminalRepr)	Traceback)LEGACY_PATH)Config)ConftestImportFailure)_check_path)NODE_CTOR_FSPATH_ARG)Mark)MarkDecorator)NodeKeywords)fail)absolutepath)
commonpath)Stash)PytestWarning)Self)_TracebackStyle)Session/_T	node_typeNodepathfspathreturnc                 C   sR   |d urt jtj| jddd |d ur|d urt|| |S |d us%J t|S )N)node_type_name   )
stacklevel)warningswarnr   format__name__r   r   )r+   r-   r.    r7   F/var/www/html/corbot_env/lib/python3.10/site-packages/_pytest/nodes.py_imply_path@   s   
r9   	_NodeType)boundc                       s<   e Zd ZdZdefddZdee def fddZ  Z	S )NodeMetaa  Metaclass used by :class:`Node` to enforce that direct construction raises
    :class:`Failed`.

    This behaviour supports the indirection introduced with :meth:`Node.from_parent`,
    the named constructor to be used instead of direct construction. The design
    decision to enforce indirection with :class:`NodeMeta` was made as a
    temporary aid for refactoring the collection tree, which was diagnosed to
    have :class:`Node` objects whose creational patterns were overly entangled.
    Once the refactoring is complete, this metaclass can be removed.

    See https://github.com/pytest-dev/pytest/projects/3 for an overview of the
    progress on detangling the :class:`Node` classes.
    r/   c                 O   s*   dj | j d| j d}t|dd d S )NzDirect construction of {name} has been deprecated, please use {name}.from_parent.
See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details..nameF)pytrace)r5   
__module__r6   r!   )clskkwmsgr7   r7   r8   __call__g   s   zNodeMeta.__call__rB   c              
      s   z
t  j|i |W S  tyC   tt| d  fdd| D }ddlm} t	||  dt
| d t  j|i | Y S w )N__init__c                    s    i | ]\}}| j v r||qS r7   )
parameters).0rC   vsigr7   r8   
<dictcomp>u   s     z$NodeMeta._create.<locals>.<dictcomp>   )PytestDeprecationWarningz7 is not using a cooperative constructor and only takes z.
See https://docs.pytest.org/en/stable/deprecations.html#constructors-of-custom-pytest-node-subclasses-should-take-kwargs for more details.)superrF   	TypeErrorr   getattritemswarning_typesrO   r3   r4   set)rB   rC   rD   known_kwrO   	__class__rK   r8   _createp   s   	zNodeMeta._create)
r6   rA   __qualname____doc__r   rF   r   r*   rY   __classcell__r7   r7   rW   r8   r<   X   s    "	r<   c                   @   sl  e Zd ZU dZeed< dZ						dGdedddee	 d	d
dee dee
 dee ddfddZedHddZedejfddZdefddZdeddfddZedefddZdefddZdIddZdId d!Zded  fd"d#Zded  fd$d%Z	&dJd'eeef d(e ddfd)d*Z!dKdee dee" fd+d,Z#	dKdee dee$d e"f  fd-d.Z%e&dedee" fd/d0Z'e&ded1e"de"fd2d0Z'	dKded1ee" dee" fd3d0Z'de(e fd4d5Z)dee fd6d7Z*d8e+g e,f ddfd9d:Z-d;e.e/ dee/ fd<d=Z0d>e1e2 de3fd?d@Z4	dKd>e1e2 dAdBde5fdCdDZ6	dKd>e1e2 dAdBdeee5f fdEdFZ7dS )Lr,   zBase class of :class:`Collector` and :class:`Item`, the components of
    the test collection tree.

    ``Collector``\'s are the internal nodes of the tree, and ``Item``\'s are the
    leaf nodes.
    r.   )r?   parentconfigsessionr-   _nodeid_store__dict__Nr?   r]   zOptional[Node]r^   r_   zOptional[Session]r-   nodeidr/   c                 C   s   || _ || _|r|| _n
|std|j| _|r|| _n
|s"td|j| _|d u r4|d u r4t|dd }tt| ||d| _t	| | _
g | _t | _|d urXd|vsTJ || _n| js_td| jjd | j  | _t | _| j| _d S )Nz!config or parent must be providedz"session or parent must be providedr-   r.   z::()z!nodeid or parent must be providedz::)r?   r]   r^   rQ   r_   rR   r9   typer-   r    keywordsown_markersrU   extra_keyword_matchesr`   rc   r$   stashra   )selfr?   r]   r^   r_   r.   r-   rc   r7   r7   r8   rG      s4   
zNode.__init__r&   c                 K   s4   d|v rt dd|v rt d| jdd|i|S )a:  Public constructor for Nodes.

        This indirection got introduced in order to enable removing
        the fragile logic from the node constructors.

        Subclasses can use ``super().from_parent(...)`` when overriding the
        construction.

        :param parent: The parent node of this Node.
        r^   z.config is not a valid argument for from_parentr_   z/session is not a valid argument for from_parentr]   Nr7   )rQ   rY   )rB   r]   rD   r7   r7   r8   from_parent   s
   zNode.from_parentc                 C   s   | j | jS )z6fspath-sensitive hook proxy used to call pytest hooks.)r_   gethookproxyr-   rj   r7   r7   r8   ihook   s   z
Node.ihookc                 C   s   d | jjt| dd S )Nz<{} {}>r?   )r5   rX   r6   rR   rm   r7   r7   r8   __repr__   s   zNode.__repr__warningc                 C   sN   t |tstd|t| \}}|dusJ tj|dt||d d dS )aw  Issue a warning for this Node.

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

        :param Warning warning:
            The warning instance to issue.

        :raises ValueError: If ``warning`` instance is not a subclass of Warning.

        Example usage:

        .. code-block:: python

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

        .. versionchanged:: 6.2
            Any subclass of :class:`Warning` is now accepted, rather than only
            :class:`PytestWarning <pytest.PytestWarning>` subclasses.
        z8warning must be an instance of Warning or subclass, got NrN   )categoryfilenamelineno)
isinstanceWarning
ValueErrorget_fslocation_from_itemr3   warn_explicitstr)rj   rp   r-   rs   r7   r7   r8   r4      s   

z	Node.warnc                 C   s   | j S )z;A ::-separated string denoting its collection tree address.)r`   rm   r7   r7   r8   rc     s   zNode.nodeidc                 C   s
   t | jS N)hashr`   rm   r7   r7   r8   __hash__!  s   
zNode.__hash__c                 C      d S rz   r7   rm   r7   r7   r8   setup$     z
Node.setupc                 C   r}   rz   r7   rm   r7   r7   r8   teardown'  r   zNode.teardownc                 c   s*    | }|dur|V  |j }|dusdS dS )zIterate over all parent collectors starting from and including self
        up to the root of the collection tree.

        .. versionadded:: 8.1
        N)r]   )rj   r]   r7   r7   r8   iter_parents*  s   zNode.iter_parentsc                 C   s4   g }| }|dur| | |j}|dus|  |S )zxReturn a list of all parent collectors starting from the root of the
        collection tree down to and including self.N)appendr]   reverse)rj   chainitemr7   r7   r8   	listchain5  s   
zNode.listchainTmarkerr   c                 C   sp   ddl m} t|tr|}nt|trt||}ntd|| j|j< |r.| j	
|j dS | j	d|j dS )zDynamically add a marker object to the node.

        :param marker:
            The marker.
        :param append:
            Whether to append the marker, or prepend it.
        r   )MARK_GENz'is not a string or pytest.mark.* MarkerN)_pytest.markr   rt   r   ry   rR   rv   rf   r?   rg   r   markinsert)rj   r   r   r   marker_r7   r7   r8   
add_marker@  s   


zNode.add_markerc                 C   s   dd | j |dD S )zIterate over all markers of the node.

        :param name: If given, filter the results by the name attribute.
        :returns: An iterator of the markers of the node.
        c                 s   s    | ]}|d  V  qdS )rN   Nr7   rI   xr7   r7   r8   	<genexpr>^  s    z$Node.iter_markers.<locals>.<genexpr>r>   )iter_markers_with_noderj   r?   r7   r7   r8   iter_markersX  s   zNode.iter_markersc                 c   sB    |   D ]}|jD ]}|du st|dd|kr||fV  q
qdS )zIterate over all markers of the node.

        :param name: If given, filter the results by the name attribute.
        :returns: An iterator of (node, mark) tuples.
        Nr?   )r   rg   rR   )rj   r?   noder   r7   r7   r8   r   `  s   

zNode.iter_markers_with_nodec                 C   r}   rz   r7   r   r7   r7   r8   get_closest_markerm  r   zNode.get_closest_markerdefaultc                 C   r}   rz   r7   rj   r?   r   r7   r7   r8   r   p  r   c                 C   s   t | j|d|S )zReturn the first marker matching the name, from closest (for
        example function) to farther level (for example module level).

        :param default: Fallback return value if no marker was found.
        :param name: Name to filter by.
        r>   )nextr   r   r7   r7   r8   r   s  s   	c                 C   s$   t  }|  D ]}||j q|S )z;Return a set of all extra keywords in self and any parents.)rU   r   updaterh   )rj   extra_keywordsr   r7   r7   r8   listextrakeywords~  s   zNode.listextrakeywordsc                 C   s   dd |   D S )Nc                 S   s   g | ]}|j qS r7   r>   r   r7   r7   r8   
<listcomp>  s    z"Node.listnames.<locals>.<listcomp>)r   rm   r7   r7   r8   	listnames  s   zNode.listnamesfinc                 C   s   | j j||  dS )zRegister a function to be called without arguments 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_   _setupstateaddfinalizer)rj   r   r7   r7   r8   r     s   zNode.addfinalizerrB   c                 C   s$   |   D ]}t||r|  S qdS )zGet the closest parent node (including self) which is an instance of
        the given class.

        :param cls: The node class to search for.
        :returns: The node, if found.
        N)r   rt   )rj   rB   r   r7   r7   r8   	getparent  s
   
zNode.getparentexcinfoc                 C   s   |j S rz   )	traceback)rj   r   r7   r7   r8   _traceback_filter  s   zNode._traceback_filterstylezOptional[_TracebackStyle]c                 C   s  ddl m} t|jtrt|jj}t|jtj	r |jj
s d}t|j|r+|j S | jddr7d}d}n	| j}|dkr@d}|d u rR| jddd	krPd	}nd}| jd
ddkr^d}nd}ztt | jjjk}W n tyx   d}Y nw |jd|| jdd|||dS )Nr   )FixtureLookupErrorvalue	fulltraceFlongautotbstyleshortverboserN   T
showlocals)funcargsabspathr   r   tbfiltertruncate_locals)_pytest.fixturesr   rt   r   r   r   from_exceptioncauser!   	Exceptionr@   
formatreprr^   	getoptionr   r   osgetcwdinvocation_paramsdirOSErrorgetrepr)rj   r   r   r   r   r   r   r7   r7   r8   _repr_failure_py  sD   
zNode._repr_failure_pyc                 C   s   |  ||S )zReturn a representation of a collection or test failure.

        .. seealso:: :ref:`non-python tests`

        :param excinfo: Exception information for the failure.
        )r   )rj   r   r   r7   r7   r8   repr_failure     zNode.repr_failure)NNNNNN)r]   r,   r/   r&   r/   N)Trz   )8r6   rA   rZ   r[   r   __annotations__	__slots__ry   r   r   r   rG   classmethodrk   propertypluggy	HookRelayrn   ro   ru   r4   rc   intr|   r~   r   r	   r   r
   r   r   r   boolr   r   r   r   r   r   r   r   r   r   r   objectr   r   r:   r   r   BaseExceptionr   r   r   r   r   r7   r7   r7   r8   r,      s   
 	
=%



	

	
:
)	metaclassr   c                 C   sL   t | dd}|dur|dd S t | dd}|durt|S t | dddfS )a  Try to extract the actual location from a node, depending on available attributes:

    * "location": a pair (path, lineno)
    * "obj": a Python object that the node wraps.
    * "path": just a path

    :rtype: A tuple of (str|Path, int) with filename and 0-based line number.
    locationN   objr-   zunknown location)rR   r   )r   r   r   r7   r7   r8   rw     s   
rw   c                   @   sp   e Zd ZdZG dd deZejdee	d  fddZ
dee de	eef fd	d
Zdee defddZdS )	CollectorzBase class of all collectors.

    Collector create children through `collect()` and thus iteratively build
    the collection tree.
    c                   @      e Zd ZdZdS )zCollector.CollectErrorz6An error during collection, contains a custom message.Nr6   rA   rZ   r[   r7   r7   r7   r8   CollectError      r   r/   )Itemr   c                 C      t d)z;Collect children (items and collectors) for this collector.abstractNotImplementedErrorrm   r7   r7   r8   collect  s   zCollector.collectr   c                 C   sX   t |j| jr| jdds|j}t|jd S | jdd}|dkr%d}| j||dS )zyReturn a representation of a collection failure.

        :param excinfo: Exception information for the failure.
        r   Fr   r   r   r   )r   )rt   r   r   r^   r   ry   argsr   )rj   r   excr   r7   r7   r8   r     s   zCollector.repr_failurec                 C   sB   t | dr|j}|j| jd}||kr|jtd}||S |jS )Nr-   r-   )excludepath)hasattrr   cutr-   tracebackcutdirfilter)rj   r   r   
ntracebackr7   r7   r8   r     s   

zCollector._traceback_filterN)r6   rA   rZ   r[   r   r   abcabstractmethodr   r   r   r   r   ry   r   r   r   r   r7   r7   r7   r8   r     s    

r   r_   r(   c                 C   sD   | j D ]}t|||krt||}|dkrd  S |  S qd S )Nr=    )_initialpathsr#   ry   relative_to)r_   r-   initial_pathrelr7   r7   r8   _check_initialpaths_for_relpath'  s   
r   c                       s   e Zd ZdZ								ddee deeeef  dee dee	 dee dee
 d	ed
 dee	 ddf fddZeddddee dee ddf fddZ  ZS )FSCollectorz%Base class for filesystem collectors.Nr.   path_or_parentr-   r?   r]   r^   r_   r(   rc   r/   c	           
         sB  |r t |tr|d u sJ tt|}nt |tr |d u sJ |}tt| ||d}|d u rV|j}|d urV|j|krVz|	|j}	W n	 t
yJ   Y nw t|	}|tjt}|| _|d u rf|d uscJ |j}|d u rzt| j	|jj}W n t
y   t||}Y nw |rtjtkr|tjt}t j||||||d d S )Nrd   )r?   r]   r^   r_   rc   r-   )rt   r,   r   r   r   r9   re   r?   r-   r   rv   ry   replacer   sepSEPr_   r^   rootpathr   rP   rG   )
rj   r.   r   r-   r?   r]   r^   r_   rc   r   rW   r7   r8   rG   2  sL   


zFSCollector.__init__)r.   r-   r&   c                   s   t  jd|||d|S )zThe public constructor.)r]   r.   r-   Nr7   )rP   rk   )rB   r]   r.   r-   rD   rW   r7   r8   rk   h  s   
zFSCollector.from_parent)NNNNNNNN)r6   rA   rZ   r[   r   r   r   r   r,   ry   r   rG   r   rk   r\   r7   r7   rW   r8   r   /  sN    	
6r   c                   @   r   )FilezOBase class for collecting tests from a file.

    :ref:`non-python tests`.
    Nr   r7   r7   r7   r8   r   u  r   r   c                   @   r   )	Directorya  Base class for collecting files from a directory.

    A basic directory collector does the following: goes over the files and
    sub-directories in the directory and creates collectors for them by calling
    the hooks :hook:`pytest_collect_directory` and :hook:`pytest_collect_file`,
    after checking that they are not ignored using
    :hook:`pytest_ignore_collect`.

    The default directory collectors are :class:`~pytest.Dir` and
    :class:`~pytest.Package`.

    .. versionadded:: 8.0

    :ref:`custom directory collectors`.
    Nr   r7   r7   r7   r8   r   |  r   r   c                	       s   e Zd ZdZdZ				ddee ded dee ddf fdd	Zdd
dZ	e
jdddZdedededdfddZdeedef ee ef fddZedeeee ef fddZ  ZS )r   zBase class of all test invocation items.

    Note that for a single function there might be multiple test invocation items.
    Nr^   r_   r(   rc   r/   c                    s6   t  j||f|||d| g | _g | _|   d S )N)r^   r_   rc   )rP   rG   _report_sectionsuser_properties-_check_item_and_collector_diamond_inheritance)rj   r?   r]   r^   r_   rc   rD   rW   r7   r8   rG     s   zItem.__init__c                 C   sd   t | }d}t||drdS t||d ddd |jD }|r0t|j d| d	t dS dS )
z
        Check if the current type inherits from both File and Collector
        at the same time, emitting a warning accordingly (#8447).
        )_pytest_diamond_inheritance_warning_shownFNTz, c                 s   s     | ]}t |tr|jV  qd S rz   )
issubclassr   r6   )rI   baser7   r7   r8   r     s    

zEItem._check_item_and_collector_diamond_inheritance.<locals>.<genexpr>zF is an Item subclass and should not be a collector, however its bases z are collectors.
Please split the Collectors and the Item into separate node types.
Pytest Doc example: https://docs.pytest.org/en/latest/example/nonpython.html
example pull request on a plugin: https://github.com/asmeurer/pytest-flakes/pull/40/)	re   rR   setattrjoin	__bases__r3   r4   r6   r%   )rj   rB   	attr_nameproblemsr7   r7   r8   r     s    
z2Item._check_item_and_collector_diamond_inheritancec                 C   r   )zRun the test case for this item.

        Must be implemented by subclasses.

        .. seealso:: :ref:`non-python tests`
        z,runtest must be implemented by Item subclassr   rm   r7   r7   r8   runtest  s   zItem.runtestwhenkeycontentc                 C   s   |r| j |||f dS dS )a  Add 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   )rj   r  r  r  r7   r7   r8   add_report_section  s   zItem.add_report_sectionzos.PathLike[str]c                 C   s   | j ddfS )aP  Get location information for this item for test reports.

        Returns a tuple with three elements:

        - The path of the test (default ``self.path``)
        - The 0-based line number of the test (default ``None``)
        - A name of the test to be shown (default ``""``)

        .. seealso:: :ref:`non-python tests`
        Nr   r   rm   r7   r7   r8   
reportinfo  r   zItem.reportinfoc                 C   sF   |   }t|d }| j|}t|d tu sJ ||d |d fS )z
        Returns a tuple of ``(relfspath, lineno, testname)`` for this item
        where ``relfspath`` is file path relative to ``config.rootpath``
        and lineno is a 0-based line number.
        r   r   rN   )r  r"   r_   _node_location_to_relpathre   ry   )rj   r   r-   	relfspathr7   r7   r8   r     s
   zItem.location)NNNNr   )r6   rA   rZ   r[   nextitemr   r   ry   rG   r   r   r   r  r  r   r   r   r  r   r   r\   r7   r7   rW   r8   r     s.    
	$&r   )Pr   	functoolsr   inspectr   r   pathlibr   typingr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r3   r   _pytest._code_pytestr   _pytest._code.coder   r   r   _pytest.compatr   _pytest.configr   r   _pytest.config.compatr   _pytest.deprecatedr   _pytest.mark.structuresr   r   r    _pytest.outcomesr!   _pytest.pathlibr"   r#   _pytest.stashr$   _pytest.warning_typesr%   r&   r'   _pytest.mainr(   r   __file__r]   r   r*   r9   r:   ABCMetar<   ABCr,   ry   r   rw   r   r   r   r   r   r   r7   r7   r7   r8   <module>   s   
,  &c/F