o
    h!                  
   @   sJ  d 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 ddlmZ erddlmZ g dZeee   Z dddde!deeeeeef  f dee" d efd!d"Z#d#ed dfd$d%Z$ed&d'd(ed eee%ef  fd)d*Z&ej'G d+d, d,Z(d-d.d(ed dfd/d0Z)ej'G d1d2 d2Z*d-d.d(ed dfd3d4Z+d5e"d6e"d e
fd7d8Z,d-d.d(ed dfd9d:Z-d(ed dfd;d<Z.d(ed dfd=d>Z/dS )?z=Generic mechanism for marking and selecting python functions.    N)AbstractSet)
Collection)List)Optional)TYPE_CHECKING)Union   )
Expression)
ParseError)EMPTY_PARAMETERSET_OPTION)get_empty_parameterset_mark)Mark)MARK_GEN)MarkDecorator)MarkGenerator)ParameterSet)Config)ExitCode)hookimpl)
UsageError)Parser)StashKey)Item)r   r   r   r   r   r    marksidvaluesr   r   returnc                 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.
    :param id: The id to attribute to this parameter set.
    r   )r   param)r   r   r   r   r   K/var/www/html/ai/venv/lib/python3.10/site-packages/_pytest/mark/__init__.pyr   +   s   r   parserc                 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 evaluatable 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'   r+   markerszMarkers for test functionslinelistz&Default marker for empty parametersets)getgroup
_addoption	addoptionaddinir   )r!   groupr   r   r    pytest_addoptionF   s0   

r6   T)tryfirstconfigc                 C   s   dd l }| jjrH|   |j| }| dD ]*}|dd}|d }t|dkr-|d nd}|j	d| dd	 |
| |
  q|   dS d S )
Nr   r/   :r      r%   z@pytest.mark.%s:T)bold)_pytest.configoptionr/   _do_configurer8   create_terminal_writergetinisplitlenwriteline_ensure_unconfigure)r8   _pytesttwrD   partsnamerestr   r   r    pytest_cmdline_mainp   s   

rK   c                   @   B   e Zd ZU dZdZee ed< edddZ	d	ede
f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.
    )_namesrN   itemr   r   c                 C   s~   t  }dd l}| D ]}t||js||j q||  t	|dd }|r/||j
 |dd | D  | |S )Nr   functionc                 s   s    | ]}|j V  qd S NrI   .0markr   r   r    	<genexpr>   s    z+KeywordMatcher.from_item.<locals>.<genexpr>)setpytest	listchain
isinstanceSessionaddrI   updatelistextrakeywordsgetattr__dict__iter_markers)clsrO   mapped_namesrX   nodefunction_objr   r   r    	from_item   s   zKeywordMatcher.from_itemsubnamec                 C   s4   |  }dd | jD }|D ]	}||v r dS qdS )Nc                 s   s    | ]}|  V  qd S rQ   )lower)rT   rI   r   r   r    rV      s    z*KeywordMatcher.__call__.<locals>.<genexpr>TF)rh   rN   )selfrg   namesrI   r   r   r    __call__   s   zKeywordMatcher.__call__N)rO   r   r   rM   __name__
__module____qualname____doc__	__slots__r   str__annotations__classmethodrf   boolrk   r   r   r   r    rM      s   
 rM   itemsz
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'rv   )
r=   r$   lstrip_parse_expressionevaluaterM   rf   appendhookpytest_deselected)rv   r8   keywordexprexpr	remaining
deselectedcolitemr   r   r    deselect_by_keyword   s   
r   c                   @   rL   )MarkMatcherzuA matcher for markers which are present.

    Tries to match on any marker names, attached to the given colitem.
    own_mark_namesr   rO   r   r   c                 C   s   dd |  D }| |S )Nc                 S   s   h | ]}|j qS r   rR   rS   r   r   r    	<setcomp>   s    z(MarkMatcher.from_item.<locals>.<setcomp>)ra   )rb   rO   
mark_namesr   r   r    rf      s   zMarkMatcher.from_itemrI   c                 C   s
   || j v S rQ   r   )ri   rI   r   r   r    rk      s   
zMarkMatcher.__call__N)rO   r   r   r   rl   r   r   r   r    r      s   
 r   c                 C   sx   |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'rw   )	r=   r,   ry   rz   r   rf   r{   r|   r}   )rv   r8   	matchexprr   r   r   rO   r   r   r    deselect_by_mark   s   
r   r   exc_messagec              
   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    ry      s   ry   c                 C   s   t | | t| | d S rQ   )r   r   )rv   r8   r   r   r    pytest_collection_modifyitems   s   
r   c                 C   s8   t j| jt< | t _| t}|dvrtdt|d S )N)skipxfailfail_at_collectNr%   zA{!s} must be one of skip, xfail or fail_at_collect but it is {!r})r   _configstashold_mark_config_keyr@   r   r   format)r8   empty_parametersetr   r   r    pytest_configure   s   
r   c                 C   s   | j td t_d S rQ   )r   getr   r   r   )r8   r   r   r    pytest_unconfigure  s   r   )0rp   dataclassestypingr   r   r   r   r   r   
expressionr	   r
   
structuresr   r   r   r   r   r   r   r<   r   r   r   r   _pytest.config.argparsingr   _pytest.stashr   _pytest.nodesr   __all__r   objectrr   r   r6   intrK   	dataclassrM   r   r   r   ry   r   r   r   r   r   r   r    <module>   sf    

* 4