HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/_pytest/__pycache__/nodes.cpython-310.pyc
o

%weFh�@s�ddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl m"Z"ddl#m$Z$ddl#m%Z%ddl&m'Z'ddl&m(Z(ddl&m)Z)dd l*m+Z+dd!l,m-Z-dd"l,m.Z.dd#l/m0Z0dd$l1m2Z2er�dd%l3m4Z4dd&lm5Z5d'Z6eej7�j8Z9d(e:d)ee:fd*d+�Z;d,ed-ed)dfd.d/�Z<d0ed1d,eed-eed)efd2d3�Z=ed4d1d5�Z>Gd6d7�d7e?�Z@Gd8d1�d1e@d9�ZAd:d1d)eee:efeeBffd;d<�ZCGd=d>�d>eA�ZDd?d@d,ed)ee:fdAdB�ZEGdCdD�dDeD�ZFGdEdF�dFeF�ZGGdGdH�dHeA�ZHdS)I�N)�	signature)�Path)�Any)�Callable)�cast)�Iterable)�Iterator)�List)�MutableMapping)�Optional)�overload)�Set)�Tuple)�Type)�
TYPE_CHECKING)�TypeVar)�Union)�getfslineno)�
ExceptionInfo)�TerminalRepr)�	Traceback)�cached_property)�LEGACY_PATH)�Config)�ConftestImportFailure)�#FSCOLLECTOR_GETHOOKPROXY_ISINITPATH)�NODE_CTOR_FSPATH_ARG)�Mark)�
MarkDecorator)�NodeKeywords)�fail)�absolutepath)�
commonpath)�Stash)�
PytestWarning)�Session)�_TracebackStyle�/�nodeid�returnccs��d}|�d�}|dkrd}dV	|�t||�}|dkrn|dkr)|d|�V|tt�}q	|�d|�}|dkr<n|dkrG|d|�V|td�}q1|rU|VdSdS)a�Return the parent node IDs of a given node ID, inclusive.

    For the node ID

        "testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_source"

    the result would be

        ""
        "testing"
        "testing/code"
        "testing/code/test_excinfo.py"
        "testing/code/test_excinfo.py::TestFormattedExcinfo"
        "testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_source"

    Note that / components are only considered until the first ::.
    r�::���N�)�find�SEP�len)r(�pos�first_colons�at�r3�F/home/arjun/projects/env/lib/python3.10/site-packages/_pytest/nodes.py�iterparentnodeids4s2�
��
�r5�path�fspathcCs&t|�|krtd|�d|�d���dS)NzPath(z) != z8
if both path and fspath are given they need to be equal)r�
ValueError)r6r7r3r3r4�_check_pathas
��r9�	node_type�NodecCsR|durtjtj|jd�dd�|dur|durt||�|S|dus%J�t|�S)N)�node_type_name���
stacklevel)�warnings�warnr�format�__name__r9r)r:r6r7r3r3r4�_imply_pathis��
rD�	_NodeType)�boundcs$eZdZdd�Z�fdd�Z�ZS)�NodeMetacOs*dj|j�d|j��d�}t|dd�dS)Nz�Direct 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)rB�
__module__rCr )�self�k�kw�msgr3r3r4�__call__�s�zNodeMeta.__call__c
s�z
t�j|i|��WStyCtt|d����fdd�|��D�}ddlm}t�	||�dt
|��d���t�j|i|��YSw)N�__init__cs i|]\}}|�jvr||�qSr3)�
parameters)�.0rN�v��sigr3r4�
<dictcomp>�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.)�superrQ�	TypeErrorr�getattr�items�
warning_typesrZr@rA�set)rMrNrO�known_kwrZ��	__class__rVr4�_create�s��	�zNodeMeta._create)rCrL�__qualname__rQrd�
__classcell__r3r3rbr4rG�s	rGc@sReZdZUdZeed<dZ						dDdedddee	d	d
deedee
deed
dfdd�ZedEdd��Z
edd��Zd
efdd�Zded
dfdd�Zed
efdd��Zd
efdd�ZdFdd�ZdFdd �Zd
edfd!d"�Z	#dGd$eeefd%ed
dfd&d'�ZdHdeed
eefd(d)�Z 	dHdeed
ee!deffd*d+�Z"e#ded
eefd,d-��Z$e#ded.ed
efd/d-��Z$	dHded.eed
eefd0d-�Z$d
e%efd1d2�Z&d
eefd3d4�Z'd5e(ge)fd
dfd6d7�Z*d8e+e,d
ee,fd9d:�Z-d;e.e/d
e0fd<d=�Z1	dHd;e.e/d>d?d
e2fd@dA�Z3	dHd;e.e/d>d?d
eee2ffdBdC�Z4dS)Ir;z�Base 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.
    r7)rJ�parent�config�sessionr6�_nodeid�_store�__dict__NrJrgzOptional[Node]rhrizOptional[Session]r6r(r)cCs�||_||_|r||_n
|std��|j|_|r||_n
|s"td��|j|_|dur4|dur4t|dd�}tt|�||d�|_t	|�|_
g|_t�|_
|durXd|vsTJ�||_n|js_td��|jjd|j|_t�|_|j|_dS)Nz!config or parent must be providedz"session or parent must be providedr6�r7z::()z!nodeid or parent must be providedr*)rJrgrhr\rir]rD�typer6r�keywords�own_markersr`�extra_keyword_matchesrjr(r#�stashrk)rMrJrgrhrir7r6r(r3r3r4rR�s4
z
Node.__init__cKs4d|vrtd��d|vrtd��|jdd|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.
        rhz.config is not a valid argument for from_parentriz/session is not a valid argument for from_parentrgNr3)r\rd)�clsrgrOr3r3r4�from_parent�s
zNode.from_parentcCs|j�|j�S)z6fspath-sensitive hook proxy used to call pytest hooks.)ri�gethookproxyr6�rMr3r3r4�ihook
sz
Node.ihookcCsd�|jjt|dd��S)Nz<{} {}>rJ)rBrcrCr]rvr3r3r4�__repr__sz
Node.__repr__�warningcCsNt|t�std�|���t|�\}}|dusJ�tj|dt|�|dd�dS)awIssue 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.
        z<warning must be an instance of Warning or subclass, got {!r}NrY)�category�filename�lineno)�
isinstance�Warningr8rB�get_fslocation_from_itemr@�
warn_explicit�str)rMryr6r|r3r3r4rAs
��
�z	Node.warncCs|jS)z;A ::-separated string denoting its collection tree address.)rjrvr3r3r4r(9szNode.nodeidcCs
t|j�S�N)�hashrjrvr3r3r4�__hash__>s
z
Node.__hash__cC�dSr�r3rvr3r3r4�setupA�z
Node.setupcCr�r�r3rvr3r3r4�teardownDr�z
Node.teardowncCs4g}|}|dur|�|�|j}|dus|��|S)z�Return list of all parent collectors up to self, starting from
        the root of collection tree.

        :returns: The nodes.
        N)�appendrg�reverse)rM�chain�itemr3r3r4�	listchainGs
�zNode.listchainT�markerr�cCspddlm}t|t�r|}nt|t�rt||�}ntd��||j|j<|r.|j	�
|j�dS|j	�d|j�dS)z�Dynamically 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�r}rr�r]r8rorJrpr��mark�insert)rMr�r�r��marker_r3r3r4�
add_markerUs


zNode.add_markercCsdd�|j|d�D�S)z�Iterate 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.
        css�|]}|dVqdS)rYNr3�rT�xr3r3r4�	<genexpr>ss�z$Node.iter_markers.<locals>.<genexpr>rI)�iter_markers_with_node�rMrJr3r3r4�iter_markersmszNode.iter_markersccsF�t|���D]}|jD]}|dust|dd�|kr||fVqqdS)z�Iterate over all markers of the node.

        :param name: If given, filter the results by the name attribute.
        :returns: An iterator of (node, mark) tuples.
        NrJ)�reversedr�rpr])rMrJ�noder�r3r3r4r�us�

���zNode.iter_markers_with_nodecCr�r�r3r�r3r3r4�get_closest_marker��zNode.get_closest_marker�defaultcCr�r�r3�rMrJr�r3r3r4r��r�cCst|j|d�|�S)z�Return 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.
        rI)�nextr�r�r3r3r4r��s	cCs$t�}|��D]}|�|j�q|S)z;Return a set of all extra keywords in self and any parents.)r`r��updaterq)rM�extra_keywordsr�r3r3r4�listextrakeywords�szNode.listextrakeywordscCsdd�|��D�S)NcSsg|]}|j�qSr3rIr�r3r3r4�
<listcomp>�sz"Node.listnames.<locals>.<listcomp>)r�rvr3r3r4�	listnames�szNode.listnames�fincCs|jj�||�dS)z�Register 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)ri�_setupstate�addfinalizer)rMr�r3r3r4r��szNode.addfinalizerrscCs@|}|rt||�s|j}|rt||�r	|dust||�sJ�|S)z�Get the next 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}rg)rMrs�currentr3r3r4�	getparent�s�zNode.getparent�excinfocCs|jSr�)�	traceback)rMr�r3r3r4�_traceback_filter�szNode._traceback_filter�stylezOptional[_TracebackStyle]cCsddlm}t|jt�rt�|jj�}t|jtj	�r |jj
s d}t|j|�r+|j��S|j�
dd�r7d}d}n	|j}|dkr@d}|durR|j�
dd�d	krPd	}nd}|j�
d
d�dkr^d}nd}z
tt���|jjjk}Wntyxd}Ynw|jd||j�
d
d�|||d�S)Nr)�FixtureLookupError�value�	fulltraceF�long�auto�tbstyle�short�verboserYT�
showlocals)�funcargs�abspathr�r��tbfilter�truncate_locals)�_pytest.fixturesr�r}r�rr�
from_exc_infor�r �	ExceptionrK�
formatreprrh�	getoptionr�r�os�getcwd�invocation_params�dir�OSError�getrepr)rMr�r�r�r�r�r�r3r3r4�_repr_failure_py�sD
��zNode._repr_failure_pycCs|�||�S)z�Return a representation of a collection or test failure.

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

        :param excinfo: Exception information for the failure.
        )r�)rMr�r�r3r3r4�repr_failure��zNode.repr_failure)NNNNNN)rgr;�r)N)Tr�)5rCrLre�__doc__r�__annotations__�	__slots__r�rrrrR�classmethodrt�propertyrwrxr~rAr(�intr�r�r�r	r�rr�boolr�rrr�rr�rr�r
r�r�r�objectr�rrEr�r�
BaseExceptionrr�rr�r�r3r3r3r4r;�s�
��������	
�=
'

�
��
�	��
�
���
�	
���
�:���
�)�	metaclassr�cCsLt|dd�}|dur|dd�St|dd�}|durt|�St|dd�dfS)aTry 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.
    * "fspath": just a path

    :rtype: A tuple of (str|Path, int) with filename and 0-based line number.
    �locationN��objr7zunknown locationr+)r]r)r�r�r�r3r3r4r�s
rc@sjeZdZdZGdd�de�Zdeedfdd�Zde	e
deeeffd	d
�Z
de	e
defdd�Zd
S)�	Collectorz�Base class of all collectors.

    Collector create children through `collect()` and thus iteratively build
    the collection tree.
    c@�eZdZdZdS)zCollector.CollectErrorz6An error during collection, contains a custom message.N�rCrLrer�r3r3r3r4�CollectError�r�r))�Itemr�cC�td��)z;Collect children (items and collectors) for this collector.�abstract��NotImplementedErrorrvr3r3r4�collectszCollector.collectr�cCsXt|j|j�r|j�dd�s|j}t|jd�S|j�dd�}|dkr%d}|j||d�S)zyReturn a representation of a collection failure.

        :param excinfo: Exception information for the failure.
        r�Frr�r�r�)r�)r}r�r�rhr�r��argsr�)rMr��excr�r3r3r4r�s�zCollector.repr_failurecCsDt|d�r|j}|j|jd�}||kr|jtd�}|j�|�S|jS)Nr6�r6)�excludepath)�hasattrr��cutr6�tracebackcutdir�filter)rMr�r��
ntracebackr3r3r4r�4s
zCollector._traceback_filterN)rCrLrer�r�r�rrr�rr�r�rr�rr�r3r3r3r4r�s�

�r�rir%cCsD|jD]}t||�|krt|�|��}|dkrdS|SqdS)NrHr,)�
_initialpathsr"r��relative_to)rir6�initial_path�relr3r3r4�_check_initialpaths_for_relpath>s
�r�cs�eZdZdZ								ddeedeeeefdeedee	deedee
d	ed
dee	ddf�fd
d�
Zeddd�deedeef�fdd��Z
ddd�Zdee	dfdefdd�Z�ZS)�FSCollectorz%Base class for filesystem collectors.Nr7�path_or_parentr6rJrgrhrir%r(r)c	
sB|r t|t�r|dus
J�tt|�}n
t|t�r |dusJ�|}tt|�||d�}|durV|j}|durV|j|krVz|�	|j�}	Wn	t
yJYnwt|	�}|�t
jt�}||_|durf|duscJ�|j}|dur�zt|j�	|jj��}Wnt
y�t||�}Ynw|r�t
jtkr�|�t
jt�}t�j||||||d�dS)Nrm)rJrgrhrir(r6)r}r;rr�rrDrnrJr6r�r8r��replacer��sepr.rirh�rootpathr�r[rR)
rMr7r�r6rJrgrhrir(r�rbr3r4rRIsL

��
�zFSCollector.__init__)r7r6cst�jd|||d�|��S)zThe public constructor.)rgr7r6Nr3)r[rt)rsrgr7r6rOrbr3r4rts
zFSCollector.from_parent�os.PathLike[str]cC�tjtdd�|j�|�S�Nr�r>)r@rArriru)rMr7r3r3r4ru��zFSCollector.gethookproxycCr�r�)r@rArri�
isinitpath)rMr6r3r3r4r��r�zFSCollector.isinitpath)NNNNNNNN)r7r�)rCrLrer�rrrrr;r�rrRr�rtrur�r�rfr3r3rbr4r�FsN��������	�
�6���
"r�c@r�)�FilezOBase class for collecting tests from a file.

    :ref:`non-python tests`.
    Nr�r3r3r3r4r��r�r�c	s�eZdZdZdZ				ddeededdeeddf�fdd	�
Zdd
d�Z	ddd
�Z
dedededdfdd�Zdee
defeeeffdd�Zedeeeeeffdd��Z�ZS)r�z�Base class of all test invocation items.

    Note that for a single function there might be multiple test invocation items.
    Nrhrir%r(r)cs6t�j||f|||d�|��g|_g|_|��dS)N)rhrir()r[rR�_report_sections�user_properties�-_check_item_and_collector_diamond_inheritance)rMrJrgrhrir(rOrbr3r4rR�s
���z
Item.__init__cCsdt|�}d}t||d�rdSt||d�d�dd�|jD��}|r0t�|j�d|�d	�t�dSdS)
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, css �|]}t|t�r|jVqdSr�)�
issubclassr�rC)rT�baser3r3r4r��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/)	rnr]�setattr�join�	__bases__r@rArCr$)rMrs�	attr_name�problemsr3r3r4r��s 
����z2Item._check_item_and_collector_diamond_inheritancecCr�)z�Run the test case for this item.

        Must be implemented by subclasses.

        .. seealso:: :ref:`non-python tests`
        z,runtest must be implemented by Item subclassr�rvr3r3r4�runtest�szItem.runtest�when�key�contentcCs|r
|j�|||f�dSdS)aAdd 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�)rMr	r
rr3r3r4�add_report_section�s�zItem.add_report_sectionr�cCs|jddfS)aPGet 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�rvr3r3r4�
reportinfo�r�zItem.reportinfocCsL|��}tt�|d��}|j�|�}t|d�tusJ�||d|dfS)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.
        rr�rY)r
r!r�r7ri�_node_location_to_relpathrnr�)rMr�r6�	relfspathr3r3r4r�s
z
Item.location)NNNNr�)rCrLrer��nextitemrrr�rRr�rrrrr�r
rr�rfr3r3rbr4r��s,�����

	$
&r�)Ir�r@�inspectr�pathlibr�typingrrrrrr	r
rrr
rrrrr�
_pytest._code�_pytestr�_pytest._code.coderrr�_pytest.compatrr�_pytest.configrr�_pytest.deprecatedrr�_pytest.mark.structuresrrr�_pytest.outcomesr �_pytest.pathlibr!r"�
_pytest.stashr#�_pytest.warning_typesr$�_pytest.mainr%r&r.�__file__rgr�r�r5r9rDrErnrGr;r�rr�r�r�r�r�r3r3r3r4�<module>s�-���
�&`.N