o
    v&i&                     @  s  d Z ddlmZ ddlZddlmZ ddlmZ ddlm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 m!Z! erddl"m#Z# g dZ$e!edB   Z%ddddJd&d'Z&dKd+d,Z'ed-d.dLd2d3Z(e	j)G d4d5 d5Z*dMd8d9Z+e	j)G d:d; d;Z,dMd<d=Z-dNdBdCZ.dMdDdEZ/dOdFdGZ0dOdHdIZ1dS )Pz=Generic mechanism for marking and selecting python functions.    )annotationsN)
Collection)Iterable)Set)TYPE_CHECKING   )
Expression)_HiddenParam)EMPTY_PARAMETERSET_OPTION)get_empty_parameterset_mark)HIDDEN_PARAM)Mark)MARK_GEN)MarkDecorator)MarkGenerator)ParameterSet)Config)ExitCode)hookimpl)
UsageError)NOT_SET)Parser)StashKey)Item)r   r   r   r   r   r   r    marksidvaluesobjectr   0MarkDecorator | Collection[MarkDecorator | Mark]r   str | _HiddenParam | Nonereturnr   c                 G  s   t j|| |dS )a$  Specify a parameter in `pytest.mark.parametrize`_ calls or
    :ref:`parametrized fixtures <fixture-parametrize-marks>`.

    .. code-block:: python

        @pytest.mark.parametrize(
            "test_input,expected",
            [
                ("3+5", 8),
                pytest.param("6*9", 42, marks=pytest.mark.xfail),
            ],
        )
        def test_eval(test_input, expected):
            assert eval(test_input) == expected

    :param values: Variable args of the values of the parameter set, in order.

    :param marks:
        A single mark or a list of marks to be applied to this parameter set.

        :ref:`pytest.mark.usefixtures <pytest.mark.usefixtures ref>` cannot be added via this parameter.

    :type id: str | Literal[pytest.HIDDEN_PARAM] | None
    :param id:
        The id to attribute to this parameter set.

        .. versionadded:: 8.4
            :ref:`hidden-param` means to hide the parameter set
            from the test name. Can only be used at most 1 time, as
            test names need to be unique.
    r   )r   param)r   r   r   r   r   [/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/_pytest/mark/__init__.pyr#   1   s   $r#   parserr   Nonec                 C  sd   |  d}|jddddddd |jd	dd
dddd |jdddd | ddd | td d S )Ngeneralz-kstorekeyword 
EXPRESSIONa  Only run tests which match the given substring expression. An expression is a Python evaluable 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', while -k 'not test_method' matches those that don't contain 'test_method' in their names. -k 'not test_method and not test_other' will eliminate the matches. 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. The matching is case-insensitive.)actiondestdefaultmetavarhelpz-mmarkexprMARKEXPRzUOnly run tests matching given mark expression. For example: -m 'mark1 and not mark2'.z	--markers
store_truez4show markers (builtin, plugin and per-project ones).)r,   r0   markersz'Register new markers for test functionslinelistz&Default marker for empty parametersets)getgroup
_addoption	addoptionaddinir
   )r%   groupr   r   r$   pytest_addoptionX   s0   

r;   T)tryfirstconfigr   int | ExitCode | Nonec                 C  s   dd l }| jjrJ|   |j| }| dD ],}|dd}|d }t|dkr-|d nd}|j	d| ddd	 |
| |
  q|   dS d S )
Nr   r4   :r      r*   z@pytest.mark.T)bold)_pytest.configoptionr4   _do_configurer=   create_terminal_writergetinisplitlenwriteline_ensure_unconfigure)r=   _pytesttwrJ   partsnamerestr   r   r$   pytest_cmdline_main   s   

rQ   c                   @  6   e Zd ZU dZdZded< eddd	ZdddZdS )KeywordMatchera  A matcher for keywords.

    Given a list of names, matches any substring of one of these names. The
    string inclusion check is case-insensitive.

    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.
    )_nameszAbstractSet[str]rT   itemr   r"   c                 C  s   t  }dd l}| D ]}t||jrqt||jr"t|j|jr"q||j q|	|
  t|dd }|r>|	|j |	dd | D  | |S )Nr   functionc                 s  s    | ]}|j V  qd S N)rO   ).0markr   r   r$   	<genexpr>   s    z+KeywordMatcher.from_item.<locals>.<genexpr>)setpytest	listchain
isinstanceSession	DirectoryparentaddrO   updatelistextrakeywordsgetattr__dict__iter_markers)clsrU   mapped_namesr\   nodefunction_objr   r   r$   	from_item   s    zKeywordMatcher.from_itemsubnamestrkwargsstr | int | bool | Noneboolc                  s,   |rt d   t fdd| jD S )Nz3Keyword expressions do not support call parameters.c                 3  s    | ]	} |  v V  qd S rW   )lower)rX   rO   rm   r   r$   rZ      s    z*KeywordMatcher.__call__.<locals>.<genexpr>)r   rr   anyrT   )selfrm   ro   r   rs   r$   __call__   s   zKeywordMatcher.__call__N)rU   r   r"   rS   )rm   rn   ro   rp   r"   rq   )	__name__
__module____qualname____doc__	__slots____annotations__classmethodrl   rv   r   r   r   r$   rS      s   
 rS   items
list[Item]c                 C  s|   |j j }|s
d S t|d}g }g }| D ]}|t|s%|| q|| q|r<|jj	|d || d d < d S d S )NzWrong expression passed to '-k'r~   )
rC   r)   lstrip_parse_expressionevaluaterS   rl   appendhookpytest_deselected)r~   r=   keywordexprexpr	remaining
deselectedcolitemr   r   r$   deselect_by_keyword   s   
r   c                   @  rR   )MarkMatcherzuA matcher for markers which are present.

    Tries to match on any marker names, attached to the given colitem.
    )own_mark_name_mappingzdict[str, list[Mark]]r   r4   Iterable[Mark]r"   c                 C  s,   t t}|D ]
}||j | q| |S rW   )collectionsdefaultdictlistrO   r   )rh   r4   mark_name_mappingrY   r   r   r$   from_markers   s   
zMarkMatcher.from_markersrO   rn   ro   rp   rq   c                  sD   | j |g  }sdS |D ] t fdd| D r dS qdS )NFc                 3  s&    | ]\}} j |t|kV  qd S rW   )ro   getr   )rX   kvrY   r   r$   rZ      s   $ z'MarkMatcher.__call__.<locals>.<genexpr>T)r   r   allr~   )ru   rO   ro   matchesr   r   r$   rv      s   zMarkMatcher.__call__N)r4   r   r"   r   )rO   rn   ro   rp   r"   rq   )	rw   rx   ry   rz   r{   r|   r}   r   rv   r   r   r   r$   r      s   
 r   c                 C  s|   |j j}|sd S t|d}g }g }| D ]}|t| r%|| q|| q|r<|jj	|d || d d < d S d S )NzWrong expression passed to '-m'r   )
rC   r1   r   r   r   r   rg   r   r   r   )r~   r=   	matchexprr   r   r   rU   r   r   r$   deselect_by_mark   s   
r   r   rn   exc_messager   c                 C  sL   zt | W S  ty% } zt| d|j d|j d|j d d }~ww )Nz: z: at column )r   compileSyntaxErrorr   textoffsetmsg)r   r   er   r   r$   r     s   r   c                 C  s   t | | t| | d S rW   )r   r   )r~   r=   r   r   r$   pytest_collection_modifyitems  s   
r   c                 C  s:   t j| jt< | t _| t}|dvrttd|d S )N)skipxfailfail_at_collectNr*   z9 must be one of skip, xfail or fail_at_collect but it is )r   _configstashold_mark_config_keyrF   r
   r   )r=   empty_parametersetr   r   r$   pytest_configure  s   
r   c                 C  s   | j td t_d S rW   )r   r   r   r   r   )r=   r   r   r$   pytest_unconfigure,  s   r   )r   r   r   r    r   r!   r"   r   )r%   r   r"   r&   )r=   r   r"   r>   )r~   r   r=   r   r"   r&   )r   rn   r   rn   r"   r   )r=   r   r"   r&   )2rz   
__future__r   r   collections.abcr   r   r   AbstractSetdataclassestypingr   
expressionr   
structuresr	   r
   r   r   r   r   r   r   r   rB   r   r   r   r   _pytest.config.argparsingr   r   _pytest.stashr   _pytest.nodesr   __all__r   r#   r;   rQ   	dataclassrS   r   r   r   r   r   r   r   r   r   r   r$   <module>   sZ    
'*
8


	
