o
    :h&                     @  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  ddlm!Z! ddl"m#Z# erddl$m%Z% g dZ&e#ee   Z'ddddLd(d)Z(dMd-d.Z)ed/d0dNd4d5Z*e	j+G d6d7 d7Z,dOd:d;Z-e	j+G d<d= d=Z.dOd>d?Z/dPdDdEZ0dOdFdGZ1dQdHdIZ2dQdJdKZ3dS )Rz=Generic mechanism for marking and selecting python functions.    )annotationsN)
Collection)Iterable)Set)Optional)TYPE_CHECKING   )
Expression)
ParseError)_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   U/var/www/html/flask_server/venv/lib/python3.10/site-packages/_pytest/mark/__init__.pyr%   3   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.   r2   markersz'Register new markers for test functionslinelistz&Default marker for empty parametersets)getgroup
_addoption	addoptionaddinir   )r'   groupr   r   r&   pytest_addoptionZ   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   r6   :r      r,   z@pytest.mark.T)bold)_pytest.configoptionr6   _do_configurer?   create_terminal_writergetinisplitlenwriteline_ensure_unconfigure)r?   _pytesttwrL   partsnamerestr   r   r&   pytest_cmdline_main   s   

rS   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]rV   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)rQ   ).0markr   r   r&   	<genexpr>   s    z+KeywordMatcher.from_item.<locals>.<genexpr>)setpytest	listchain
isinstanceSession	DirectoryparentaddrQ   updatelistextrakeywordsgetattr__dict__iter_markers)clsrW   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 rY   )lower)rZ   rQ   ro   r   r&   r\      s    z*KeywordMatcher.__call__.<locals>.<genexpr>)r   rt   anyrV   )selfro   rq   r   ru   r&   __call__   s   zKeywordMatcher.__call__N)rW   r   r$   rU   )ro   rp   rq   rr   r$   rs   )	__name__
__module____qualname____doc__	__slots____annotations__classmethodrn   rx   r   r   r   r&   rU      s   
 rU   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   )
rE   r+   lstrip_parse_expressionevaluaterU   rn   appendhookpytest_deselected)r   r?   keywordexprexpr	remaining
deselectedcolitemr   r   r&   deselect_by_keyword   s   
r   c                   @  rT   )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   r6   Iterable[Mark]r$   c                 C  s,   t t}|D ]
}||j | q| |S rY   )collectionsdefaultdictlistrQ   r   )rj   r6   mark_name_mappingr[   r   r   r&   from_markers   s   
zMarkMatcher.from_markersrQ   rp   rq   rr   rs   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 rY   )rq   getr   )rZ   kvr[   r   r&   r\      s   $ z'MarkMatcher.__call__.<locals>.<genexpr>T)r   r   allr   )rw   rQ   rq   matchesr   r   r&   rx      s   zMarkMatcher.__call__N)r6   r   r$   r   )rQ   rp   rq   rr   r$   rs   )	ry   rz   r{   r|   r}   r~   r   r   rx   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   )
rE   r3   r   r   r   r   ri   r   r   r   )r   r?   	matchexprr   r   r   rW   r   r   r&   deselect_by_mark  s   
r   r   rp   exc_messager	   c              
   C  s@   zt | W S  ty } zt| d|  d| d d }~ww )Nz: )r	   compiler
   r   )r   r   er   r   r&   r     s   r   c                 C  s   t | | t| | d S rY   )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_keyrH   r   r   )r?   empty_parametersetr   r   r&   pytest_configure  s   
r   c                 C  s   | j td t_d S rY   )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   rp   r   rp   r$   r	   )r?   r   r$   r(   )4r|   
__future__r   r   collections.abcr   r   r   AbstractSetdataclassestypingr   r   
expressionr	   r
   
structuresr   r   r   r   r   r   r   r   r   rD   r   r   r   r   _pytest.config.argparsingr   r   _pytest.stashr   _pytest.nodesr   __all__r   r%   r=   rS   	dataclassrU   r   r   r   r   r   r   r   r   r   r   r&   <module>   s^    
'*
8



